event not fired after table.ajax.reload()

event not fired after table.ajax.reload()

itramitram Posts: 41Questions: 14Answers: 0

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

  • itramitram Posts: 41Questions: 14Answers: 0

    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,

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    I think I'd need a link to your page showing the issue to be able to debug this one please.

    Allan

  • itramitram Posts: 41Questions: 14Answers: 0

    is it possible to share the link confidentially? I need to share link and also username and password.

  • itramitram Posts: 41Questions: 14Answers: 0

    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) {
    .....
    });
    });

  • kthorngrenkthorngren Posts: 20,144Questions: 26Answers: 4,736
    Answer ✓

    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 the table #members from the DOM when you are using ajax.reload()?

    Maybe you can update the test case t show the issue.

    Kevin

  • itramitram Posts: 41Questions: 14Answers: 0

    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.

  • kthorngrenkthorngren Posts: 20,144Questions: 26Answers: 4,736

    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

Sign In or Register to comment.