I'm hoping to implement a search box that automatically receives an AJAX request to get search results Activates. However, I only want to do this that the user has 'typing finished' (after a delay of 2 seconds).
I thought that the right way to go around it would be to use the queue, while cleansing the line a new letter is typed, to ensure that one setout can be stopped, the animation But I am not able to apply it correctly.
$ ('.js-header-search-box'). ('Input property paste paste', function () {// stop current queued $ ('.js-header-search-box'). Dequeue (); // search var q = $ (this) .val () ; $ ('.js-header-search-box'). Queue (function () {setTimeout (SearchAccounts (q), 2000);})});
$ ('.js-header-search-box'). ('Event property's paste', function (event) {// stop current queue search if (event.target.timeout) // wrong if undefined clear timeout (event.target.timeout); // search var q = $ (Event .target) .val (); event.target.timeout = setTimeout (function () {SearchAccounts (q)}, 2000);});
No comments:
Post a Comment