Skip to content

Instantly share code, notes, and snippets.

@ynniv
Created January 24, 2010 06:09
Show Gist options
  • Save ynniv/285042 to your computer and use it in GitHub Desktop.
Save ynniv/285042 to your computer and use it in GitHub Desktop.
/** @private - setup observer on init if needed. */
init: function() {
sc_super();
if (this.get('content')) this._scoc_contentDidChange();
if (this.get('observableContent')) this._scoc_observableContentDidChange();
},
_scoc_contentDidChange: function () {
var last = this._scoc_content,
cur = this.get('content');
if (last !== cur) {
var cofunc = this._scoc_contentObjectsDidChange;
if (last && last.isEnumerable) last.removeObserver('[]', this, cofunc);
if (cur && cur.isEnumerable) cur.addObserver('[]', this, cofunc);
}
}.observes("content"),
_scoc_contentObjectsDidChange: function () {
this.propertyDidChange('content');
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment