Skip to content
Permalink
Browse files

Widget delegation: First draft

  • Loading branch information
jzaefferer committed Jun 8, 2011
1 parent 0e9f87f commit 2d1b9b391eadc979fb0988a76055ab5397e8b55f
Showing with 11 additions and 2 deletions.
  1. +11 −2 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 );
}
});
},

0 comments on commit 2d1b9b3

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