aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJörn Zaefferer <joern.zaefferer@gmail.com>2011-06-08 22:14:37 +0200
committerJörn Zaefferer <joern.zaefferer@gmail.com>2011-06-08 22:14:37 +0200
commit2d1b9b391eadc979fb0988a76055ab5397e8b55f (patch)
treef86f9de456616e433b965a08ef7c544435fac4a3
parent0e9f87f15b6b961243f5ee3b20e34331f107c849 (diff)
downloadjquery-ui-2d1b9b391eadc979fb0988a76055ab5397e8b55f.tar.gz
jquery-ui-2d1b9b391eadc979fb0988a76055ab5397e8b55f.zip
Widget delegation: First draft
-rw-r--r--ui/jquery.ui.widget.js13
1 files changed, 11 insertions, 2 deletions
diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js
index 00bc07c4f..1c01ef7c9 100644
--- a/ui/jquery.ui.widget.js
+++ b/ui/jquery.ui.widget.js
@@ -301,9 +301,10 @@ $.Widget.prototype = {
element = $( element );
this.bindings = this.bindings.add( element );
}
+
var instance = this;
$.each( handlers, function( event, handler ) {
- element.bind( event + "." + instance.widgetName, function() {
+ function handlerProxy() {
// allow widgets to customize the disabled handling
// - disabled as an array instead of boolean
// - disabled class as method for disabling individual parts
@@ -313,7 +314,15 @@ $.Widget.prototype = {
}
return ( typeof handler === "string" ? instance[ handler ] : handler )
.apply( instance, arguments );
- });
+ }
+ var match = key.match( /^(\w+)\s*(.*)$/ );
+ var eventName = match[1] + "." + instance.widgetName,
+ selector = match[2];
+ if (selector === '') {
+ element.bind( eventName, handlerProxy );
+ } else {
+ element.delegate( selector, eventName, handlerProxy );
+ }
});
},