Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge _collectionOptionsByCid & _modelOptionsByCid

  • Loading branch information...
commit 7a1dd6f48db146709c53fb919c6393c0e88250cf 1 parent 333b2ab
Ryan Eastridge authored
View
5 src/collection.js
@@ -40,7 +40,6 @@ createRegistryWrapper(Thorax.Collection, Thorax.Collections);
dataObject('collection', {
name: '_collectionEvents',
array: '_collections',
- hash: '_collectionOptionsByCid',
set: 'setCollection',
setCallback: afterSetCollection,
bind: 'bindCollection',
@@ -189,7 +188,7 @@ _.extend(Thorax.View.prototype, {
return element.length === 0 ? this.$el : element;
},
_onCollectionReset: function(collection) {
- if (collection === this.collection && this._collectionOptionsByCid[this.collection.cid].render) {
+ if (collection === this.collection && this._objectOptionsByCid[this.collection.cid].render) {
this.renderCollection();
}
},
@@ -233,7 +232,7 @@ _.extend(Thorax.View.prototype, {
Thorax.View.on({
collection: {
error: function(collection, message) {
- if (this._collectionOptionsByCid[collection.cid].errors) {
+ if (this._objectOptionsByCid[collection.cid].errors) {
this.trigger('error', message, collection);
}
}
View
10 src/data-object.js
@@ -61,21 +61,21 @@ function dataObject(type, spec) {
this[spec.array] = _.without(this[spec.array], dataObject);
dataObject.trigger('freeze');
this.stopListening(dataObject);
- delete this[spec.hash][dataObject.cid];
+ delete this._objectOptionsByCid[dataObject.cid];
return true;
}
function objectOptions(dataObject, options) {
- if (!this[spec.hash][dataObject.cid]) {
- this[spec.hash][dataObject.cid] = {
+ if (!this._objectOptionsByCid[dataObject.cid]) {
+ this._objectOptionsByCid[dataObject.cid] = {
render: true,
fetch: true,
success: false,
errors: true
};
}
- _.extend(this[spec.hash][dataObject.cid], options || {});
- return this[spec.hash][dataObject.cid];
+ _.extend(this._objectOptionsByCid[dataObject.cid], options || {});
+ return this._objectOptionsByCid[dataObject.cid];
}
function setObject(dataObject, options) {
View
2  src/form.js
@@ -8,7 +8,7 @@ extendOptions('_setModelOptions', function() {
extendViewMember('_onModelChange', function(model) {
// TODO : What can we do to remove this duplication?
- var modelOptions = model && this._modelOptionsByCid[model.cid];
+ var modelOptions = model && this._objectOptionsByCid[model.cid];
if (modelOptions && modelOptions.populate) {
this.populate(model.attributes, modelOptions.populate === true ? {} : modelOptions.populate);
}
View
5 src/model.js
@@ -26,7 +26,6 @@ createRegistryWrapper(Thorax.Model, Thorax.Models);
dataObject('model', {
name: '_modelEvents',
array: '_models',
- hash: '_modelOptionsByCid',
set: 'setModel',
bind: 'bindModel',
unbind: 'unbindModel',
@@ -38,7 +37,7 @@ dataObject('model', {
_.extend(Thorax.View.prototype, {
_onModelChange: function(model) {
- var modelOptions = model && this._modelOptionsByCid[model.cid];
+ var modelOptions = model && this._objectOptionsByCid[model.cid];
// !modelOptions will be true when setModel(false) is called
if (!modelOptions || (modelOptions && modelOptions.render)) {
this.render();
@@ -49,7 +48,7 @@ _.extend(Thorax.View.prototype, {
Thorax.View.on({
model: {
error: function(model, errors) {
- if (this._modelOptionsByCid[model.cid].errors) {
+ if (this._objectOptionsByCid[model.cid].errors) {
this.trigger('error', errors, model);
}
},
View
5 src/thorax.js
@@ -45,11 +45,12 @@ Thorax.View = Backbone.View.extend({
_configure: function(options) {
var self = this;
+ this._objectOptionsByCid = {};
+
// Setup object event tracking
_.each(inheritVars, function(obj) {
self[obj.name] = [];
if (obj.array) { self[obj.array] = []; }
- if (obj.hash) { self[obj.hash] = {}; }
});
viewsIndexedByCid[this.cid] = this;
@@ -189,7 +190,7 @@ Thorax.View = Backbone.View.extend({
} else {
this.el.innerHTML = "";
var element;
- if (this.collection && this._collectionOptionsByCid[this.collection.cid] && this._renderCount) {
+ if (this.collection && this._objectOptionsByCid[this.collection.cid] && this._renderCount) {
// preserveCollectionElement calls the callback after it has a reference
// to the collection element, calls the callback, then re-appends the element
preserveCollectionElement.call(this, function() {
Please sign in to comment.
Something went wrong with that request. Please try again.