backbone.js - Undo view change after backbone sync fails -
i'm quite confused backbone's view rendering. need regarding this.
for example, i've album view. it's render method renders each track view. track specific events binding in track view.
now, track view listening it's model. example:
this.model.on('destroy', this.destroy, this); destroy: function(model){ this.close(); },
so when track destroyed, view removed ui fine. problem sync. view removed ui not server. if sync successful, nothing view.
however, if sync not successful, want undo view change (restore track markup before destroyed it).
can please tell how can this?
fyi, earlier i've altered ui after getting success server. in more 98% cases success, decided change ui , restore when there error.
there's great plugin dealing this: https://github.com/derickbailey/backbone.memento
Comments
Post a Comment