0

I am using jquery datatables plugin. The row click functionality is working fine on the first page, when I go to any of the next pages, the row click doesn't work with .on("click", function() { ....});

I tried to replace .on() with .live() and seems to work fine. My concern is .live() has been deprecated since jquery 1.7. Is it a bug with the .on() or am I missing something ?

0

1 Answer 1

2

If you want to delegate the event using on method, you should code:

$(document).on("click", "selector", function() { ....});

or:

$('staticParent').on("click", "dynamicDescendant", function() { ....});
Sign up to request clarification or add additional context in comments.

3 Comments

Isn't the selector optional? If the selector is null or omitted, the event is always triggered when it reaches the selected element. api.jquery.com/on
@Liam For regular event handling, yes, but for event delegation, no.
I think I see the issue so the OP is doing $(selector).on(....); and your saying it should be $(document).on('click', selector....); :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.