Reputation: 2490
I want to bind a tr click event to my datatable.
This is my code now:
$(myDataTable).find("tbody tr").on("click", function (e) {
//do the magic
});
It works for the first page. On second page i got no click event.
.live and .delegate also not work.
Anyone with a solution and can say why this is not working? I would prefer not to use the dataTables render callbacks.
Upvotes: 1
Views: 49
Reputation: 115222
To work with dynamic element use the following code
$(myDataTable).on("click","tbody tr", function (e) {
//do the magic
});
Documentation : http://api.jquery.com/on/
Upvotes: 1
Reputation: 32581
To bind to dynamic elements you must do this
$(myDataTable).on("click","tbody tr", function (e) {
//do the magic
});
.on( events [, selector ] [, data ], handler(eventObject) )
Upvotes: 1