#delegate returns view

This commit is contained in:
Justin Ridgewell
2015-05-23 20:33:35 -04:00
parent 5c8c40fe37
commit fda1f62824
2 changed files with 4 additions and 1 deletions

View File

@@ -1270,6 +1270,7 @@
// `blur`, and not `change`, `submit`, and `reset` in Internet Explorer.
delegate: function(eventName, selector, listener) {
this.$el.on(eventName + '.delegateEvents' + this.cid, selector, listener);
return this;
},
// Clears all callbacks previously bound to the view by `delegateEvents`.

View File

@@ -77,7 +77,7 @@
equal(counter2, 3);
});
test("delegate", 2, function() {
test("delegate", 3, function() {
var view = new Backbone.View({el: '#testElement'});
view.delegate('click', 'h1', function() {
ok(true);
@@ -86,6 +86,8 @@
ok(true);
});
view.$('h1').trigger('click');
equal(view.delegate(), view, '#delegate returns the view instance');
});
test("delegateEvents allows functions for callbacks", 3, function() {