We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9003c2d commit de867bbCopy full SHA for de867bb
1 file changed
select2.js
@@ -195,13 +195,18 @@
195
*
196
* @param quietMillis number of milliseconds to wait before invoking fn
197
* @param fn function to be debounced
198
+ * @param thisobj object to be used as this reference within fn
199
* @return debounced version of fn
200
*/
- function debounce(quietMillis, fn) {
201
+ function debounce(quietMillis, fn, thisobj) {
202
+ thisobj = thisobj || undefined;
203
var timeout;
204
return function () {
205
+ var args = arguments;
206
window.clearTimeout(timeout);
- timeout = window.setTimeout(fn, quietMillis);
207
+ timeout = window.setTimeout(function() {
208
+ fn.apply(thisobj, args);
209
+ }, quietMillis);
210
};
211
}
212
0 commit comments