Adding .change() to filter input
Adding .change() to filter input
bcraig
Posts: 8Questions: 2Answers: 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();
This discussion has been closed.
Answers
This alert is actioned but table is not updated with the inputs new;y set value.
Solved this myself..