simplified the bindAll example

This commit is contained in:
Jeremy Ashkenas
2009-12-07 00:26:00 -05:00
parent f2670259d1
commit 21e0cbc229

View File

@@ -646,11 +646,7 @@ var buttonView = {
onClick : function(){ alert('clicked: ' + this.label); },
onHover : function(){ console.log('hovering: ' + this.label); }
};
// In this case, the following two lines have the same effect.
_.bindAll(buttonView, 'onClick', 'onHover');
_(buttonView).bindAll();
_.bindAll(buttonView);
jQuery('#underscore_button').bind('click', buttonView.onClick);
=> When the button is clicked, this.label will have the correct value...
</pre>