mirror of
https://github.com/jashkenas/backbone.git
synced 2026-04-30 03:00:06 -04:00
#delegate returns view
This commit is contained in:
@@ -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`.
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user