JQuery Event handler issue

JQuery Event handler issue

radi8radi8 Posts: 31Questions: 6Answers: 0

Referencing the example here: https://datatables.net/examples/advanced_init/events_live.html

I am trying to use the double click event on my datatable. It works on the first page of data, but the double click event fails to trigger on subsequent pages.

Essentially, I am passing a JSON to a custom function to build the datatable. After I build the table, I put it into a div. At this point I am using the following code to bind the dblclick event to all of the elements in the table with a "id_check" class.

Here I am working with a table with an id of "cu_table_display" and telling it to bind on the double click on class "id_check" elements.

 $('#cu_table_display tbody .id_check').on('dblclick',function(event){
    cl.get_details($(this).closest('tr').find('.id_check').val());
 });

Why would this work on only the first page of data?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,789Questions: 26Answers: 5,041
    Answer ✓

    Checkout the second FAQ here:
    https://datatables.net/faqs/index#Most-common-FAQs

    Kevin

  • radi8radi8 Posts: 31Questions: 6Answers: 0

    Oh crap, I see. The event should have been like this:

    $('#cu_table_display tbody ').on('dblclick','.id_check', function(event){
       cl.get_details($(this).closest('tr').find('.id_check').val());
    });
    

    I had the class in the wrong position of the event handler.

    I knew it was something simple.

    Thanks!

This discussion has been closed.