diff options
author | Andy Knotts <arknotts@gmail.com> | 2011-04-10 07:41:05 -0700 |
---|---|---|
committer | Andy Knotts <arknotts@gmail.com> | 2011-04-10 07:41:05 -0700 |
commit | 42cfa3f57112408c5886d103a9d28e1134cfba0f (patch) | |
tree | c675cc22ffda425334baaeab1fd4730113ce72cb | |
parent | 943dbd34b130bba3ab79f4413259f7de8d8badd8 (diff) | |
download | askbot-42cfa3f57112408c5886d103a9d28e1134cfba0f.tar.gz askbot-42cfa3f57112408c5886d103a9d28e1134cfba0f.tar.bz2 askbot-42cfa3f57112408c5886d103a9d28e1134cfba0f.zip |
Modified live_search.js javascript to reduce the number of roundtrips to the server.
-rw-r--r-- | askbot/skins/default/media/js/live_search.js | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/askbot/skins/default/media/js/live_search.js b/askbot/skins/default/media/js/live_search.js index 4151124b..b94ecf07 100644 --- a/askbot/skins/default/media/js/live_search.js +++ b/askbot/skins/default/media/js/live_search.js @@ -61,9 +61,11 @@ var liveSearch = function(){ var ask_page_search_listen = function(){ running = false; - query.keydown(function(e){ + var ask_page_eval_handle; + query.keyup(function(e){ if (running === false){ - setTimeout(eval_query, 50); + clearTimeout(ask_page_eval_handle); + ask_page_eval_handle = setTimeout(eval_query, 400); } }); }; @@ -71,15 +73,14 @@ var liveSearch = function(){ var main_page_search_listen = function(){ running = false; refresh_x_button(); - query.keydown(function(e){ + var main_page_eval_handle; + query.keyup(function(e){ refresh_x_button(); if (running === false){ - setTimeout(eval_query, 50); + clearTimeout(main_page_eval_handle); + main_page_eval_handle = setTimeout(eval_query, 400); } }); - query.keyup(function(){ - refresh_x_button(); - }); }; var render_counter = function(count, word, counter_class, counter_subclass){ |