Skip to content

Instantly share code, notes, and snippets.

@ozgun
Created September 10, 2012 07:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ozgun/3689533 to your computer and use it in GitHub Desktop.
Save ozgun/3689533 to your computer and use it in GitHub Desktop.
live search delay
$(document).ready(function() {
var d = new Date();
var search_timer = d.getTime();
var time_range = 1000;
$('#site_search_q2').live('keyup', function(event){
if ($(this).val().length > 2) {
var d2 = new Date();
var new_search_time = d2.getTime();
//console.log(new_search_time - search_timer);
if (new_search_time - search_timer > time_range) {
setTimeout("$('#site_search_form2').submit()", 1000);
} else {
//
}
search_timer = new_search_time;
//$('#site_search_form2').submit();
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment