Un-golf #delegateEvents

This commit is contained in:
Justin Ridgewell
2015-05-23 20:41:31 -04:00
parent 8266bd4609
commit 1f4fb29323

View File

@@ -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));