3

I've got a view with a few exposed filters. Is there a way to change the submit speed of the ajax request? So that rather than submitting the request after every key press, it waits until no keypress has been registered for say 500ms before submitting the request? I'm having problems, especially on mobile, where you might type "ar" in the exposed filter, but end up seeing the results for "a", with the filter set back to "a".

1 Answer 1

3
function do_search(e) {
  clearTimeout(search_timer);
  search_timer = setTimeout(function() {
    var v = $("#YOUR_INPUT_VAR_ID").val();
    p(v);
    CALL THE AJAX HERE
  }, 500);
}
1
  • Basic idea for seems right, but I didn't try it. I found the timer in ctools/js/auto-submit.js. Since I wanted to make the change everywhere, so I cheated and modified things that, rather than add something custom. So, in a roundabout way, thanks for the lead. Commented Mar 7, 2012 at 0:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.