diff --git a/backbone.js b/backbone.js index bb4ebf3b..fa0dba72 100644 --- a/backbone.js +++ b/backbone.js @@ -291,7 +291,16 @@ // Set a hash of model attributes, and sync the model to the server. // If the server returns an attributes hash that differs, the model's // state will be `set` again. - save : function(attrs, options) { + save : function(key, value, options) { + var attrs; + if (_.isObject(key) || key == null) { + attrs = key; + options = value; + } else { + attrs = {}; + attrs[key] = value; + } + options = options ? _.clone(options) : {}; if (attrs && !this.set(attrs, options)) return false; var model = this; diff --git a/test/model.js b/test/model.js index e60dba69..19806682 100644 --- a/test/model.js +++ b/test/model.js @@ -331,6 +331,15 @@ $(document).ready(function() { ok(_.isEqual(lastRequest[1], doc)); }); + test("Model: save in positional style", function() { + var model = new Backbone.Model(); + model.sync = function(method, model, options) { + options.success(); + }; + model.save('title', 'Twelfth Night'); + equals(model.get('title'), 'Twelfth Night'); + }); + test("Model: fetch", function() { doc.fetch(); ok(lastRequest[0], 'read');