Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix delegate usage of on() binder #52

Merged
merged 2 commits into from

3 participants

@nelsonmenezes

The current usage of on() with a delegate selector is broken. It doesn't use the correct (jQuery) syntax. This should fix it.

@mythz mythz merged commit a1d4fdc into mythz:master
@mythz
Owner

Cool, thx!

@statianzo
Collaborator

Nice catch @nelsonmenezes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 28, 2013
  1. @nelsonmenezes
  2. @nelsonmenezes

    Fixed unbinding of delegated events via on().

    nelsonmenezes authored
    Ammended tests to use correct syntax.
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 8 deletions.
  1. +2 −2 src/jquip.events.js
  2. +6 −6 test/spec/events.js
View
4 src/jquip.events.js
@@ -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 () {
View
12 test/spec/events.js
@@ -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();
@@ -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();
@@ -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();
Something went wrong with that request. Please try again.