2 save methods (sync) in Backbone.js - one to persist and a final complete method
I'm wondering if anyone has had any experience in saving开发者_如何学运维 the model, .sync
, with a persistent auto-save (localStorage) AND a full save/confirm (RESTful JSON request).
I've been using the backbone-localstorage adapter that overrides the default behaviour but I was wondering if there is a more elegant way than just adding a switch in a custom sync function.
function autoSave(model) {
model.sync = localStorageSync;
model.save();
delete model.sync;
}
No need to change Backbone.sync
精彩评论