Wednesday, 15 February 2012

javascript - Cancel existing calls to the api when doing findQuery emberjs and ember data -



javascript - Cancel existing calls to the api when doing findQuery emberjs and ember data -

i have input field live search. set every key press store.findquery fires api request. i've noticed using need cancel pending ajax calls api each new findquery executed. there ends beingness loads of request irrelevant search query has changed. know how this?

there no built in way it. ajax phone call isn't returned type of use. recommend debouncing find requests avoid making ton of useless requests.

app.indexcontroller = em.controller.extend({ foo:undefined, callstosearch: 0, actualsearch: 0, watchfoo: function(){ this.incrementproperty('callstosearch'); //context, method, time must elapse before calling method em.run.debounce(this, this.dosearch, 300); }.observes('foo'), dosearch: function(){ this.incrementproperty('actualsearch'); // actual search here } });

http://emberjs.jsbin.com/ciyebaqo/1/edit

javascript ember.js ember-data

No comments:

Post a Comment