jquery-archive / jquery-mobile

jQuery Mobile Framework
https://jquerymobile.com
Other
9.7k stars 2.41k forks source link

Programatically enabling native selects causes error #966

Closed adammessinger closed 13 years ago

adammessinger commented 13 years ago

Programatically enabling native select menus using the code given in the select docs renders a jQM site unusable and produces the following error in Firebug:

$.mobile.selectmenu is undefined

Example here

scottjehl commented 13 years ago

typo in code example. Closed by 0745af1292dfa35e1744200283ba79c8e8162303

adammessinger commented 13 years ago

I already noticed and corrected for that in the example I posted, which uses "nativeMenu" instead of "nativemenu". There's still a JS error.

johnbender commented 13 years ago

scott,

I commented a bit later on this here:

https://github.com/jquery/jquery-mobile/commit/67987925b43b427040a5a56e438de1e636716941

The select menu isn't defined on mobileinit just as page wasn't previously. We had to move page above core in the build process to fix that issue. It was a temporary fix in that case and doesn't really make sense in this case either.

It might be time to sort out a simple way to configure the widgets before they are created. Possibly defining their options hash before defining the widget itself?

    $mobile.selectmenu.options 

Which can then be used when the widgets are built.

johnbender commented 13 years ago

scott,

[update: config -> options naming convention]

https://github.com/johnbender/jquery-mobile/compare/f944333...config

Thats a sample configuration setup that could be used like so:

    $(document).bind('mobileinit',function(){
        $.mobile.options.selectmenu.nativeMenu = true;
    });

and is pretty trivial to implement with the current widgets and include order.

johnbender commented 13 years ago

I'm consulting the team on my proposed solution. Hopefully we'll get this sorted out in the next day or so.

Thanks for your patience adam.

johnbender commented 13 years ago

closed with:

https://github.com/jquery/jquery-mobile/commit/891f9b1b07ce13922619266054ce54cb791319d4

kurteknikk commented 13 years ago

I'm not sure if this has to do with the same issue. Basically i was looking for a function to disable the "removing of null value" from the select box and i found the code below in the docs:

$.mobile.selectmenu.prototype.options.hidePlaceholderMenuItems = false;

But when i include it within the mobileinit function it complains that mobile.selectmenu is undefined.