【发布时间】:2015-07-26 17:19:12
【问题描述】:
我在输入文本字段上从 keyPress 侦听器调用以下函数。 _.debounce() 工作正常,除了在时间段之后仅触发函数 1 次,它触发的次数与 keyPress 事件发生的次数一样多。
console.log("Pre Debounce");
var debounced = _.debounce(function() {
console.log("Field updated!");
}, 2000);
debounced();
有没有办法将 _.debounce 函数限制为仅在时间段后触发 1 次?
【问题讨论】:
标签: javascript backbone.js underscore.js