Created
August 14, 2011 18:45
-
-
Save yaotti/1145166 to your computer and use it in GitHub Desktop.
Model.create({ success: function(){...}})とか書きたくないので関数追加した.もっと綺麗にできればいいんだけど無理そう.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Return Backbone.sync's retval instead of the saved model | |
// to use the deferred object ($.ajax: jsdeferred.jquery.js). | |
Backbone.Collection.prototype.createDeferred = function(model, options) { | |
var coll = this; | |
options || (options = {}); | |
model = this._prepareModel(model, options); | |
if (!model) return false; | |
return model.save(null, options); | |
}; | |
// var collection = Backbone.Collection.extend(); | |
// collection.createDeferred(this.newAttributes()) | |
// .next(function(response) { | |
// var models = _(response).map(function(row) { | |
// return new SomeModel(row); | |
// }); | |
// // do something... | |
// }).error(function(e) { | |
// console.error(e); | |
// }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment