fnagel / jquery-ui

A fork of jQuery UI: WIP branches, legacy Selectmenu Widget (branch: selectmenu) and an accessible version of jQuery UI Tabs (outdated, branch: tabs accessability)
Other
588 stars 141 forks source link

Disable does not work in certain circumstance #12

Closed fnagel closed 13 years ago

fnagel commented 14 years ago

This seems to be an bug which needs more investigation. Following code is an example in which the links (#on and #off) work but the select callback does not. The disable function within the method always calls the enable method of the jQuery UI widget.js. I just don't know why.

This needs further investigation, but seems to be a UI internal problem. Help is appreciated!

JS var speedB = $('select#speedB').selectmenu();

        var speedA = $('select#speedA').selectmenu({
            select: function(event, options) {
                if (options.value) { 
                    speedB.selectmenu('enable');
                } else {
                    speedB.selectmenu('disable');
                }
            }
        });

        $("#on").click(function(){
            speedB.selectmenu("enable");
        });

        $("#off").click(function(){
            speedB.selectmenu("disable");
        });

HTML on
off

Default: "popup" Style

```

Same with option text formatting



</code>
KosmoNut commented 13 years ago

The true portion of the IF branch was always being called because options.value was always a string.

I got the demo working by changing the IF condition to "if (!options.index)..."

fnagel commented 13 years ago

I will check this asap. Thanks your your contribution.

fnagel commented 13 years ago

Does not work for me with your snippet but this way:

select: function(event, options) {
    if (options.value == "on") { 
        speedA_depends.selectmenu('enable');
    } else {
        speedA_depends.selectmenu('disable');
    }
}

Thanks for your idea for checking the type of the passed value.

Closed as "fixed" :-)