Created
December 5, 2011 18:23
-
-
Save rgrove/1434662 to your computer and use it in GitHub Desktop.
YUI ModelList monkeypatch to allow model instances from other YUI sandboxes
This file contains 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
Y.ModelList.prototype._add = function (model, options) { | |
var facade; | |
options || (options = {}); | |
if (!(model instanceof Y.Model || (model._yuid && model.lists))) { | |
model = new this.model(model); | |
} | |
if (this._clientIdMap[model.get('clientId')]) { | |
this.fire('error', { | |
error: 'Model is already in the list.', | |
model: model, | |
src : 'add' | |
}); | |
return; | |
} | |
facade = Y.merge(options, { | |
index: this._findIndex(model), | |
model: model | |
}); | |
options.silent ? this._defAddFn(facade) : this.fire('add', facade); | |
return model; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment