mirror of
https://github.com/jashkenas/backbone.git
synced 2026-04-30 03:00:06 -04:00
attaching url and urlRoot on the model if passed
This commit is contained in:
@@ -244,6 +244,8 @@
|
||||
var attrs = attributes || {};
|
||||
this.cid = _.uniqueId('c');
|
||||
this.attributes = {};
|
||||
if (options && options.url) this.url = options.url;
|
||||
if (options && options.urlRoot) this.urlRoot = options.urlRoot;
|
||||
if (options && options.collection) this.collection = options.collection;
|
||||
if (options && options.parse) attrs = this.parse(attrs, options) || {};
|
||||
if (defaults = _.result(this, 'defaults')) {
|
||||
|
||||
@@ -111,6 +111,13 @@ $(document).ready(function() {
|
||||
equal(model.url(), '/nested/1/collection/2');
|
||||
});
|
||||
|
||||
test('url and urlRoot are directly attached if passed in the options', 2, function () {
|
||||
var model = new Backbone.Model({a: 1}, {url: '/test'});
|
||||
var model2 = new Backbone.Model({a: 2}, {urlRoot: '/test2'});
|
||||
equal(model.url, '/test');
|
||||
equal(model2.urlRoot, '/test2');
|
||||
});
|
||||
|
||||
test("underscore methods", 5, function() {
|
||||
var model = new Backbone.Model({ 'foo': 'a', 'bar': 'b', 'baz': 'c' });
|
||||
var model2 = model.clone();
|
||||
|
||||
Reference in New Issue
Block a user