event not fired after table.ajax.reload()
event not fired after table.ajax.reload()
After table.ajax.reload() to update data in the table, the following event is not fired in the updated table:
$("#members").on("change", "td.isCheckBox input.editor-active", function(e) {
......
});
if I put the on change event above in the console, the event is fired, but it seems that some kind or refresh is needed, or am I missing something else??
Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
This question has an accepted answers - jump to answer
Answers
ok, I ended adding the event handler in the ajax.reload callback. Not sure if it the correct way to do it, but it works,
I think I'd need a link to your page showing the issue to be able to debug this one please.
Allan
is it possible to share the link confidentially? I need to share link and also username and password.
if it helps to address the issue:
ajax.reload() returns rows that did not exists before.
In fact, when the page loads it returns an empty table, then user selects some params and then the ajax.reload() returns the appropiate rows.
I guess that the jquery event handler must be recreated after the ajax.reload() is completed. Am I right?
Actually it works in this way:
members.ajax.reload(function() {
$("#members").on("change", "td.isCheckBox input.editor-active", function(e) {
.....
});
});
You event handler code works in this test case:
http://live.datatables.net/cowojuhi/1/edit
There is no data loaded on initialization. Click the button to execute
ajax.reload()
and you will see the click event works. Are you removing thetable
#members
from the DOM when you are usingajax.reload()
?Maybe you can update the test case t show the issue.
Kevin
Yes, it works, thanks.
I don't know what was wrong because apparently I did the same, but I started from your example and added my stuff. Now it works.
I was not using:
"processing": true,
"serverSide": true,
deferLoading: 0
Is it necessary? I never used before. I am using editor.
No, you don't need those options if you aren't using them. They were used just for the test case setup to not load data on initialization.
Kevin