$ ("#foo"). Bind ("click", Function () {
Alert ("User clicked on ' foo.");
});
On aliases
var object = {};
_.extend (object, backbone.events);
Object.on ("Alert", Function (msg) {
Alert ("triggered" + msg);
});
Object.trigger ("Alert", "an event");
Object gets the ability to bind and trigger custom name events after extend Backbone.events.
On aliases
Bind
_.bind (function, object, *arguments)
var func = function (greeting) {return greeting + ': ' + this.name};
Func = _.bind (func, {name: ' Moe '}, ' Hi ');
Func ();
= ' Hi:moe '
When you bind a function to a object,function call, this points to object.
Bindall _.bindall (object, *methodnames)
Binding a methods to a object,function call with a series of methodnames in the context of the object.
Function.prototype.bind ()
Fun.bind (thisarg[, arg1[, arg2[, ...])
It has little to do with the other three kinds of bind.
Bind/on in JavaScript, JQuery, Backbone, underscore