Hello,
I am having trouble disabling/re-enabling a button that I've created outside of my datatable. I have 3 datasets that I displaying using the ajax request found here https://datatables.net/reference/api/ajax.url(). I used a call similar to the one from the example table.ajax.url( 'newData.json' ).load();. I use a nav menu I have created on trigger the dataset load on a jQuery click event handler. When the page initially loads, I have no problem disabling the button through a check selection. The problem occurs when I load a different dataset. The clicks on the checkboxes do not register when inspecting it through the browser.
To add a checkbox, I do the following within my column:
'render': function (data, type, full, meta){
return '<input class="doc-selection-row" name="doc-selection-row" type="checkbox">';
},
I also have an init function that I used to disable my button on dataload:
initComplete: function () {
$('#account-div input:checkbox').change(function(){
$("#delete-btn").prop("disabled", $('#account-div input:checkbox:checked').length ===0);
});
}
}
and Finally, these are my click handlers to navigate between the data:
$("#finance").click(function() {
table.ajax.url('/finance/docs').load();
});
$("#accounting").click(function() {
table.ajax.url('/accounting/docs').load();
});
$("#sales").click(function() {
table.ajax.url('/sales/docs').load();
});
Again, when I initially load the page, I have no problem disabling and enabling the button on a checkbox selection. The problem is when i navigate to another dataset is where I am unable to do what I need to do. Also, When navigating back to the default dataset, the button disable/enable no longer works. I need to reload the page.
Thanks again!