backbone.js - detect when a backbone collection has been fetched (Backbone 1.0.0) -


there's new behaviour in latest version of backbone (1.0.0 in reset event no longer triggered default after fetching collection.

http://backbonejs.org/#changelog

renamed collection's "update" set, parallelism similar model.set(), , contrast reset. it's default updating mechanism after fetch. if you'd continue using "reset", pass {reset: true}.

the problem want capture event when collection has been fetched (pretty common case, indeed!)

i listen add, remove , change event, if collection empty don't know how catch event.

so, new, recommended way catch when collection request has finalized, or passing { reset = true } way achieve it???

ps: here's original question, btw can't catch backbone collection reset event

from backbone.sync doc,

whenever model or collection begins sync server, "request" event emitted. if request completes you'll "sync" event, , "error" event if not.

for example,

var c = backbone.collection.extend({     url: '/echo/json/' });  var c = new c(); c.on('sync', function() {     console.log('sync'); }); c.fetch(); 

and demo http://jsfiddle.net/nikoshr/glatm/


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -