javascript - how can i sync two Backbone fetch calls with JQuery WHEN and THEN -
i found out cool thing in jquery: can do:
$.when([$.get(..), $.ajax(...), $.getjson(...)]).then(function(data1,data2,data3){ // code run when requests done }); this great when want sync many ajax calls.
in backbone ajax call being issued every time fetch model or collection:
cardscollection.fetch(); my question how can achieve similar syncing capabilities backbone model/collection fetching:
i like:
$.when([series.fetch(), cardscollection.fetch()]).then(function(){ cardslistview.seriesid = seriesid; cardslistview.seriesname = series.get('seriesname'); cardslistview.template = _.template(cardslisttemplate); cardslistview.render(); $('#loader').hide(); }); is possible?
tnx. ;-)
yes, it's possible. pass several deferred jquery.when: $.when(series.fetch(), cardscollection.fetch()).then(...)
Comments
Post a Comment