]> source.dussan.org Git - jquery-ui.git/commitdiff
Widget: Use this.widget() for event delegation.
authorScott González <scott.gonzalez@gmail.com>
Sat, 13 Aug 2011 02:10:31 +0000 (22:10 -0400)
committerScott González <scott.gonzalez@gmail.com>
Sat, 13 Aug 2011 02:10:31 +0000 (22:10 -0400)
tests/unit/widget/widget_core.js
ui/jquery.ui.widget.js

index 8cacdd47de9c01e09bee2dd77f612a9f893b5a9f..41ae8ffb458e6a9e11eb04c38409a0d4efe21486 100644 (file)
@@ -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"
index 4c538d020fe5c3b6f9ab55350358c382fcdc80f1..5b7942600aaa4d5c61ff80fa2ab289e53387844b 100644 (file)
@@ -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 );
                        }