Created
June 6, 2012 03:02
-
-
Save hafriedlander/2879591 to your computer and use it in GitHub Desktop.
Possible remote event binding for Entwine.js
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
/* | |
Old style. Problems: onmatch is slow. Leaks memory, because there's a reference from window to this node, and window exists forever, so that reference holds this DOM node out of the garbage once it's removed from the document. | |
*/ | |
$('.node').entwine({ | |
onmatch: function(){ | |
var self = this; | |
$(window).bind('load', function(){ self.initialise(); }); | |
}, | |
initialise: function(){ | |
} | |
}); | |
/* | |
New method. Uses event delegation, so immediately active. By centralizing logic, hopefully eliminates memory leaks. | |
*/ | |
$('.node').entwine({ | |
initialise: $.entwine.delegate(window, 'load', function(){ | |
}), | |
myParentHasChanged: $.entwine.delegate(function(){ return this.parent(); }, 'change', function(){ | |
}) | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sort of. They're real functions, and can be overloaded, called with _super, etc. It's up to the dev to pick a good key that's explanatory & not confusing.