开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜