mirror of
https://github.com/jashkenas/backbone.git
synced 2026-04-30 03:00:06 -04:00
Un-golf #delegateEvents
This commit is contained in:
@@ -1252,11 +1252,12 @@
|
||||
// Uses event delegation for efficiency.
|
||||
// Omitting the selector binds the event to `this.el`.
|
||||
delegateEvents: function(events) {
|
||||
if (!(events || (events = _.result(this, 'events')))) return this;
|
||||
events || (events = _.result(this, 'events'));
|
||||
if (!events) return this;
|
||||
this.undelegateEvents();
|
||||
for (var key in events) {
|
||||
var method = events[key];
|
||||
if (!_.isFunction(method)) method = this[events[key]];
|
||||
if (!_.isFunction(method)) method = this[method];
|
||||
if (!method) continue;
|
||||
var match = key.match(delegateEventSplitter);
|
||||
this.delegate(match[1], match[2], _.bind(method, this));
|
||||
|
||||
Reference in New Issue
Block a user