]> source.dussan.org Git - jquery-ui.git/commitdiff
Widget factory: Fixed $4266 - Add custom selectors for widgets.
authorScott González <scott.gonzalez@gmail.com>
Sat, 28 Mar 2009 00:52:56 +0000 (00:52 +0000)
committerScott González <scott.gonzalez@gmail.com>
Sat, 28 Mar 2009 00:52:56 +0000 (00:52 +0000)
ui/ui.core.js

index 7c1ea8ca9b3a08d63b4c9c2ef87055ee394715b0..d95ec747b5149ed7c3d6ee5374beb2ad33391a7c 100644 (file)
@@ -217,9 +217,16 @@ function getter(namespace, plugin, method, args) {
 }
 
 $.widget = function(name, prototype) {
-       var namespace = name.split(".")[0];
+       var namespace = name.split(".")[0],
+               fullName;
        name = name.split(".")[1];
+       fullName = namespace + '-' + name;
 
+       // create selector for plugin
+       $.expr[':'][fullName] = function(elem) {
+               return !!$.data(elem, name);
+       };
+       
        // create plugin method
        $.fn[name] = function(options) {
                var isMethodCall = (typeof options == 'string'),
@@ -259,7 +266,7 @@ $.widget = function(name, prototype) {
                this.namespace = namespace;
                this.widgetName = name;
                this.widgetEventPrefix = $[namespace][name].eventPrefix || name;
-               this.widgetBaseClass = namespace + '-' + name;
+               this.widgetBaseClass = fullName;
 
                this.options = $.extend(true, {},
                        $.widget.defaults,