Datatable JS Pesquisa servidor depois do tempo ou comprimento da palavra
initComplete: function() {
var api = this.api();
var searchWait = 0;
var searchWaitInterval;
// Grab the datatables input box and alter how it is bound to events
$(".dataTables_filter input")
.unbind() // Unbind previous default bindings
.bind("input", function(e) { // Bind our desired behavior
var item = $(this);
searchWait = 0;
if(!searchWaitInterval) searchWaitInterval = setInterval(function(){
searchTerm = $(item).val();
// if(searchTerm.length >= 3 || e.keyCode == 13) {
clearInterval(searchWaitInterval);
searchWaitInterval = '';
// Call the API search function
api.search(searchTerm).draw();
searchWait = 0;
// }
searchWait++;
},2000);
return;
});
},
Amr Moniem