Skip to content

Commit

Permalink
Merge pull request #52 from nelsonmenezes/event-on
Browse files Browse the repository at this point in the history
Fix delegate usage of on() binder
  • Loading branch information
mythz committed Feb 28, 2013
2 parents 6614325 + 069482f commit a1d4fdc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/jquip.events.js
Expand Up @@ -128,11 +128,11 @@ $['plug']("events", function($){
};

p['on'] = function(evt, sel, cb){
return typeof sel === 'function' ? this.bind(evt, sel) : this.delegate(evt, sel, cb);
return typeof sel === 'function' ? this.bind(evt, sel) : this.delegate(sel, evt, cb);
};

p['off'] = function(evt, sel, cb){
return typeof sel === 'string' ? this.undelegate(evt, sel, cb) : this.unbind(evt, cb);
return typeof sel === 'string' ? this.undelegate(sel, evt, cb) : this.unbind(evt, cb);
};
p['trigger'] = function (evt) {
return this['each'](function () {
Expand Down
12 changes: 6 additions & 6 deletions test/spec/events.js
Expand Up @@ -122,7 +122,7 @@
var spy = jasmine.createSpy('cb'),
inner = $('<span>').appendTo(el);

el.on('span', 'click', spy);
el.on('click', 'span', spy);
inner.click();

expect(spy).toHaveBeenCalled();
Expand All @@ -132,8 +132,8 @@
var spy = jasmine.createSpy('cb'),
inner = $('<span>').appendTo(el);

el.on('span', 'click', spy);
el.off('span', 'click', spy);
el.on('click', 'span', spy);
el.off('click', 'span', spy);
inner.click();

expect(spy).not.toHaveBeenCalled();
Expand All @@ -144,10 +144,10 @@
spy2 = jasmine.createSpy('cb2'),
inner = $('<span>').appendTo(el);

el.on('span', 'click', spy);
el.on('span', 'click', spy2);
el.on('click', 'span', spy);
el.on('click', 'span', spy2);

el.off('span', 'click');
el.off('click', 'span');
inner.click();

expect(spy).not.toHaveBeenCalled();
Expand Down

0 comments on commit a1d4fdc

Please sign in to comment.