From 6072703cd17a04b0de83b337534fd0c12e24aa88 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 18 Jan 2011 01:53:20 -0500 Subject: [PATCH] Widget: Added "dynamic" bindings via ._bind() to allow for proxying. --- tests/unit/widget/widget_core.js | 4 ++-- ui/jquery.ui.widget.js | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js index f0afaa956..5ed0717da 100644 --- a/tests/unit/widget/widget_core.js +++ b/tests/unit/widget/widget_core.js @@ -412,7 +412,7 @@ test( "_bind to element (default)", function() { self = this; this._bind({ keyup: this.keyup, - keydown: this.keydown + keydown: "keydown" }); }, keyup: function( event ) { @@ -452,7 +452,7 @@ test( "_bind to descendent", function() { self = this; this._bind( this.element.find( "strong" ), { keyup: this.keyup, - keydown: this.keydown + keydown: "keydown" }); }, keyup: function( event ) { diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 4d786e5c6..dd7992da2 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -130,11 +130,7 @@ $.Widget.prototype = { options ); this.bindings = $(); - - var self = this; - this.element.bind( "remove." + this.widgetName, function() { - self.destroy(); - }); + this._bind({ remove: "destroy" }); this._create(); this._trigger( "create" ); @@ -233,7 +229,8 @@ $.Widget.prototype = { if ( instance.options.disabled ) { return; } - return handler.apply( instance, arguments ); + return ( typeof handler === "string" ? instance[ handler ] : handler ) + .apply( instance, arguments ); }); }); }, -- 2.39.5