Skip to content

Instantly share code, notes, and snippets.

@rgrove
Created December 5, 2011 18:23
Show Gist options
  • Save rgrove/1434662 to your computer and use it in GitHub Desktop.
Save rgrove/1434662 to your computer and use it in GitHub Desktop.
YUI ModelList monkeypatch to allow model instances from other YUI sandboxes
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