javascript ajax show result type min 3 characters

Solutions on MaxInterview for javascript ajax show result type min 3 characters by the best coders in the world

showing results for - "javascript ajax show result type min 3 characters"
Julia
08 May 2016
1// Call datatables, and return the API to the variable for use in our code
2// Binds datatables to all elements with a class of datatable
3var dtable = $(".datatable").dataTable().api();
4
5// Grab the datatables input box and alter how it is bound to events
6$(".dataTables_filter input")
7    .unbind() // Unbind previous default bindings
8    .bind("input", function(e) { // Bind our desired behavior
9        // If the length is 3 or more characters, or the user pressed ENTER, search
10        if(this.value.length >= 3 || e.keyCode == 13) {
11            // Call the API search function
12            dtable.search(this.value).draw();
13        }
14        // Ensure we clear the search if they backspace far enough
15        if(this.value == "") {
16            dtable.search("").draw();
17        }
18        return;
19    });
20