r2784 - modified _setData method to apply disabled toggling to all widget elements, not just the ...

r2784 - modified _setData method to apply disabled toggling to all widget elements, not just the ...


Author: scottjehl
Date: Tue Jun 16 12:58:41 2009
New Revision: 2784
Modified:
branches/labs/selectmenu/ui.selectmenu.js
Log:
modified _setData method to apply disabled toggling to all widget elements,
not just the native select
Modified: branches/labs/selectmenu/ui.selectmenu.js
==============================================================================
--- branches/labs/selectmenu/ui.selectmenu.js    (original)
+++ branches/labs/selectmenu/ui.selectmenu.js    Tue Jun 16 12:58:41 2009
@@ -280,7 +280,10 @@
        //update value
        if(o.value){ this.value(o.value); }
        else { this._refreshValue(); }
-        this._setData("value", this._selectedIndex());
+        this.value(this._selectedIndex());
+        
+        //transfer disabled state
+        if(this.element.attr('disabled') == true){ this.disable(); }
    },
    destroy: function() {
        this.newelement.remove();
@@ -412,6 +415,19 @@
        };
        this._trigger("change", event, uiHash);
    },
+    _setData: function(key, value) {
+        this.options[key] = value;
+        this._refreshValue();
+        if (key == 'disabled') {
+            this.element
+                .add(this.newelement)
+                .add(this.list)
+                    [value ? 'addClass' : 'removeClass'](
+                        this.widgetBaseClass + '-disabled' + ' ' +
+                        this.namespace + '-state-disabled')
+                    .attr("aria-disabled", value);
+        }
+    },
    value: function(newValue) {
        if (arguments.length) {
            this._setData("value", newValue);
@@ -421,10 +437,6 @@
            this._change(null, 0);
        }
        return this._value();
-    },
-    _setData: function(key, value) {
-        $.widget.prototype._setData.apply(this, arguments);
-        this._refreshValue();
    },
    _value: function() {
        var val = this.options.value;