Quantcast
Channel: Free community support — DataTables forums
Viewing all articles
Browse latest Browse all 35808

Adding .change() to filter input

$
0
0

With my filter input for my datatable I have suggestions that appear below on .keyup() such like autocomplete. When clicking on a suggestion this changes the value of the filter input. How can I attach this event to update my datatable?

$('#filterInput').keyup(function(){
        if($(this).val().length !=0){
                $(this).next().fadeTo("slow", 1.0).css({cursor:"default"}); // fades in suggestion container
        suggestion(this, $(this).attr('tables')); // calls function that retrieves suggestions from database
        } else {
                $(this).next().fadeTo("slow", 0).css({cursor:"default"}); // input empty, no suggestions
    }
  });

Would I insert somewhere above: onchange - trigger filter update.

OR maybe I would put a trigger in my suggestion click function?

$(".suggestions").click(function(){
        $("#filterInput").value() = value;
        $('#filterInput').trigger('change');
});

    $('#filterInput').on('change', function() {
        var oTable = $('#table').dataTable();
        oTable2.fnDraw();
    });

OR would I add this trigger in the datatable call.. $('#table').DataTable();


Viewing all articles
Browse latest Browse all 35808

Trending Articles