Binding to the length select menu

Binding to the length select menu

fookfook Posts: 5Questions: 0Answers: 0
edited March 2010 in General
I need to make an ajax call whenever the length selection is changed in datatables. I know how to make the ajax call, but I'm unsure how to bind it to the length select menu in datatables. What is the method for doing this?

Replies

  • vexvex Posts: 30Questions: 0Answers: 0
    For the dropdown the 'change' event (http://api.jquery.com/change/) is the one you want to bind to, it should only fire if the value is changed.
  • fookfook Posts: 5Questions: 0Answers: 0
    edited March 2010
    Here is the code I used for anyone interested.
    [code]
    $('#myTable_length').change( function() {
    var lengthVal = $('#myTable_length:selected').val();
    $.post("ajax.cfm", { displayLength: lengthVal } );
    } );
    [/code]

    This will bind to the change event of the length dropdown and post a request via ajax. It took some playing with, but I'm learning!
This discussion has been closed.