Skip to content
This repository has been archived by the owner on Mar 20, 2021. It is now read-only.

Commit

Permalink
Add defaultOptions spec option
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Eastridge committed Dec 26, 2012
1 parent 7a1dd6f commit 92b7e4d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
6 changes: 6 additions & 0 deletions src/collection.js
Expand Up @@ -45,6 +45,12 @@ dataObject('collection', {
bind: 'bindCollection',
unbind: 'unbindCollection',
options: '_setCollectionOptions',
defaultOptions: {
render: true,
fetch: true,
success: false,
errors: true
},
change: '_onCollectionReset',
$el: 'getCollectionElement',
cidAttrName: collectionCidAttributeName
Expand Down
9 changes: 2 additions & 7 deletions src/data-object.js
Expand Up @@ -67,14 +67,9 @@ function dataObject(type, spec) {

function objectOptions(dataObject, options) {
if (!this._objectOptionsByCid[dataObject.cid]) {
this._objectOptionsByCid[dataObject.cid] = {
render: true,
fetch: true,
success: false,
errors: true
};
this._objectOptionsByCid[dataObject.cid] = {};
}
_.extend(this._objectOptionsByCid[dataObject.cid], options || {});
_.extend(this._objectOptionsByCid[dataObject.cid], spec.defaultOptions, options);
return this._objectOptionsByCid[dataObject.cid];
}

Expand Down
6 changes: 6 additions & 0 deletions src/model.js
Expand Up @@ -30,6 +30,12 @@ dataObject('model', {
bind: 'bindModel',
unbind: 'unbindModel',
options: '_setModelOptions',
defaultOptions: {
render: true,
fetch: true,
success: false,
errors: true
},
change: '_onModelChange',
$el: '$el',
cidAttrName: modelCidAttributeName
Expand Down

0 comments on commit 92b7e4d

Please sign in to comment.