I am trying to send data to a server via Backbone if users write or insert a string inside a text input element.
in Backbone events, I thought something like this, but it doesn't work:
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); }
vitto source share