Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Mobile displays hidden select element

See this select element with display:none. In jQuery Mobile it is displayed despite this:

<select id="dddd" name="dddd"
        data-mini="true" data-native-menu="false" data-theme="c"
        onChange=""
        style="display:none">     
  <option value="1">An optinos</option>
</select>

I'm trying to show/hide jQuery Mobile select elements dependent on other user actions hence why I'm doing the above.

Any ideas?

like image 809
IanOSullivan Avatar asked Aug 15 '12 11:08

IanOSullivan


1 Answers

When your page loads, jQuery Mobile enhances your page to have it the mobile look-and-feel. Unfortunately, there is currently an issue with jQuery mobile that it cannot attach custom classes (and even custom styles, by the style attribute) to enhanced elements. Please check https://github.com/jquery/jquery-mobile/issues/3577 for the issue. As a workaround while this issue is still not resolved, you may actually wrap it inside a div element and control the display of the div wrapper instead.

<div id="dddd-wrapper" class="ui-screen-hidden">
  <select data-mini="true" data-native-menu="false" id="dddd" name="dddd" data-theme="c"     onChange="" style="display:none">     
    <option value="1">An optinos</option>
  </select>
</div>

ui-screen-hidden is a jquery mobile defined style rule (in jquery.mobile..css) for hiding an element.

like image 85
jay c. Avatar answered Nov 06 '22 10:11

jay c.