Skip to content

Commit de867bb

Browse files
kylegibson-rldatixivaynberg
authored andcommitted
Pass along arguments sent to debounce
Signed-off-by: Igor Vaynberg <igor.vaynberg@gmail.com>
1 parent 9003c2d commit de867bb

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

select2.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,18 @@
195195
*
196196
* @param quietMillis number of milliseconds to wait before invoking fn
197197
* @param fn function to be debounced
198+
* @param thisobj object to be used as this reference within fn
198199
* @return debounced version of fn
199200
*/
200-
function debounce(quietMillis, fn) {
201+
function debounce(quietMillis, fn, thisobj) {
202+
thisobj = thisobj || undefined;
201203
var timeout;
202204
return function () {
205+
var args = arguments;
203206
window.clearTimeout(timeout);
204-
timeout = window.setTimeout(fn, quietMillis);
207+
timeout = window.setTimeout(function() {
208+
fn.apply(thisobj, args);
209+
}, quietMillis);
205210
};
206211
}
207212

0 commit comments

Comments
 (0)