I am using Jquery DataTables 1.7.6 with JQuery 1.8.6. I am trying to setup a datatable that has a button in one row and then capture the click of that button to move the row to another table. I'm having a problem getting at the data in the DataTable to call the add and remove functions.
<script type="text/javascript">
$(document).ready(function () {
var eligibleCreatives = $('#EligibleCreativeTableId').dataTable({
"bJQueryUI": true,
"bStateSave": true,
"bAutoWidth": false,
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [0] },
{ "bVisible": false, "aTargets": [3] },
],
"aaSorting": [[1, "asc"]]
});
associatedCreatives = $('#AssociatedCreativeTableId').dataTable({
"bJQueryUI": true,
"bStateSave": true,
"bAutoWidth": false,
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [0] },
{ "bVisible": false, "aTargets": [3] },
],
"aaSorting": [[1, "asc"]]
});
eligibleCreatives.$('tr').click(function () {
var data = .fnGetData( this );
// this tells me that eligibleCreatives has no method $
});
$('#disassociate-creative').click(function () {
//I can't get at the actual row node here.
var data = associatedCreatives.fnGetData($(this).closest('tr')[0]);
eligibleCreatives.fnAddData(data);
associatedCreatives.fnDeleteRow(this);
return false;
});
$('#associate-creative').click(function () {
var data = associatedCreatives.fnGetData($(this).closest('tr')[0]);
associatedCreatives.fnAddData(data);
eligibleCreatives.fnDeleteRow(this);
return false;
});
});
function fnClickAssociate() {
$('#AssociatedCreativeTableId').dataTable().fnDeleteRow();
$('#AssociatedCreativeTableId').dataTable().fnAddData([]);
}
</script>