有什么方法可以部分覆盖 Backbone.sync,比如说,只有create
and update
,离开read
并delete
使用本机 Backbone.sync?
问问题
1024 次
1 回答
4
就那么简单:
// retain original sync with new name
Backbone.ajaxSync = Backbone.sync;
Backbone.customSync = function(method, model, option) {
// Fallback for old sync method
if (method == 'read' || method == 'delete') return Backbone.ajaxSync(method, model, option);
// your custom code for other methods
console.log('Custom sync for ' + method);
}
Backbone.sync = Backbone.customSync;
于 2012-10-03T12:39:16.327 回答