Backbone
如果用户在输入文本元素中写入或粘贴字符串,我正在尝试将数据发送到服务器。
在 Backbone 事件中,我想到了这样的事情,但它不起作用:
events:{
"click .close":"closeResults",
"keypress input":"fetchData",
"paste input":"fetchData"
},
fetchData:function (e) {
var $this = this;
window.setTimeout(function () {
if ($.trim(e.target.value).length >= 3) {
console.log(e.target.value);
$this.collection.fetch({data: {limit: 10, term:$.trim(e.target.value)}});
}
}, 0);
}