mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 18:17:48 +00:00
simplified the bindAll example
This commit is contained in:
@@ -646,11 +646,7 @@ var buttonView = {
|
|||||||
onClick : function(){ alert('clicked: ' + this.label); },
|
onClick : function(){ alert('clicked: ' + this.label); },
|
||||||
onHover : function(){ console.log('hovering: ' + this.label); }
|
onHover : function(){ console.log('hovering: ' + this.label); }
|
||||||
};
|
};
|
||||||
|
_.bindAll(buttonView);
|
||||||
// In this case, the following two lines have the same effect.
|
|
||||||
_.bindAll(buttonView, 'onClick', 'onHover');
|
|
||||||
_(buttonView).bindAll();
|
|
||||||
|
|
||||||
jQuery('#underscore_button').bind('click', buttonView.onClick);
|
jQuery('#underscore_button').bind('click', buttonView.onClick);
|
||||||
=> When the button is clicked, this.label will have the correct value...
|
=> When the button is clicked, this.label will have the correct value...
|
||||||
</pre>
|
</pre>
|
||||||
|
|||||||
Reference in New Issue
Block a user