Skip to content
Permalink
Browse files

Widget: Use this.widget() for event delegation.

  • Loading branch information
scottgonzalez committed Aug 13, 2011
1 parent 1729e3a commit 4587f2de68a884bc6d749728bfd6a555efb14b54
Showing with 20 additions and 12 deletions.
  1. +19 −11 tests/unit/widget/widget_core.js
  2. +1 −1 ui/jquery.ui.widget.js
@@ -673,23 +673,31 @@ test( "_bind() with delegate", function() {
this.element = {
bind: function( event, handler ) {
equal( event, "click.testWidget" );
ok( $.isFunction(handler) );
},
delegate: function( selector, event, handler ) {
equal( selector, "a" );
equal( event, "click.testWidget" );
ok( $.isFunction(handler) );
ok( $.isFunction(handler) );
},
trigger: $.noop
};
this.widget = function() {
return {
delegate: function( selector, event, handler ) {
equal( selector, "a" );
equal( event, "click.testWidget" );
ok( $.isFunction(handler) );
}
};
};
this._bind({
"click": "handler",
"click a": "handler",
"click a": "handler"
});
this.element.delegate = function( selector, event, handler ) {
equal( selector, "form fieldset > input" );
equal( event, "change.testWidget" );
ok( $.isFunction(handler) );
this.widget = function() {
return {
delegate: function( selector, event, handler ) {
equal( selector, "form fieldset > input" );
equal( event, "change.testWidget" );
ok( $.isFunction(handler) );
}
};
};
this._bind({
"change form fieldset > input": "handler"
@@ -326,7 +326,7 @@ $.Widget.prototype = {
eventName = match[1] + "." + instance.widgetName,
selector = match[2];
if ( selector ) {
element.delegate( selector, eventName, handlerProxy );
instance.widget().delegate( selector, eventName, handlerProxy );
} else {
element.bind( eventName, handlerProxy );
}

0 comments on commit 4587f2d

Please sign in to comment.
You can’t perform that action at this time.