I'm using jQuery DataTables 1.10.9 and trying to change the search function in jQuery DataTables, so that it needs at least 3 characters before it starts searching. So I read that you need to unbind the current datatables searchbox like so:
$(".dataTables_filter input").unbind().bind("keyup", function(){
alert("whoo");
});
So now it should alert whoo
when i type anything in the searchbox, but it just does the normal search function. So my guess is that it's not getting the correct field. I have also tried:
$('.input[type="search"]').unbind().bind("keyup", function(){
alert("whoo");
});
but that didn't help either.
var dt = $('#example').DataTable({
"order": [[11, "desc"]],
"processing": true,
"serverSide": true,
"ajax": "/datatables/test" + id,
"language": {
"url": "http://cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Dutch.json"
}
});
EDIT
I did try the code from jQuery DataTables: Delay search until 3 characters been typed OR a button clicked
But since i didn't get that working, i posted this question.
My guess that it isn't working is that it just cant find the input form, but i cant understand why, so ill post my html here as well.
<input type="hidden" id="q" name="q" value="<?php echo $_GET['q']; ?>"/>
<table id="example" class="table table-hover" cellspacing="0" width="100%">
<?php if($_GET['k_id'] != ""){?>
<input type = "hidden" value = "<?php echo $_GET['k_id']; ?>" id = "k_id" />
<?php }elseif($_GET['w_id'] != ""){ ?>
<input type="hidden" value="<?php echo $_GET['w_id']; ?>" id="w_id"/>
<?php } ?>
<thead>
This page is about looking up every product there is currently in the database. The 3 input fields are there so when a user is looking on a profile of someone and he wants to see what products they have for sale it will fill up a variable and send it to the datatables function like so. (that also explains why the +id is behind the ajax url)
if($('#k_id').val() > 0) {
var id = "?k_id=" + $('#k_id').val();
}else if($('#w_id').val()){
var id = "?w_id=" + $('#w_id').val();
}else{
var id = "";
}
The input form is inside a div with id=example_filter and class= dataTables_filter (i'd upload a picture but i dont have 10 rep yet xd).