I'm using jQuery's selectMenu on a select tag like this.
$('#ddlReport').selectmenu()
in certain cases I want to hide it, and I can't figure out how.
this doesn't work:
$('#ddlReport').selectmenu().hide();
neither does this
$('#ddlReport').hide();
anyone?
After losing a few hours trying to figure this out. I finally wrapped the thing in a <div>
and just show/hide on the div. Certainly far from elegant but it keeps me out of the jq mobile innards.
With newer versions of jQueryUI (I'm working with version 1.11.4), simply use the "widget" attribute:
$("#element").selectmenu( "widget" ).hide();
Looking at the demos here and here, it seems selectmenu works by appending a
<span class="ui-selectmenu-button">
or (probably different selectmenu versions?)
<a ... class="ui-selectmenu ...">
after the original select, containing the artificial select.
You could try accessing that using
$('#ddlReport').next('.ui-selectmenu .ui-selectmenu-button').hide();
Though it sounds like it may use other classes (instead of -button
). This is also a kind of hackish workaround and I'm sure the plugin contains some way intended to let you access the newly appended menu.
Edit: Looking through the code in the second demo, it doesn't seem like there is any preprogrammed way to access the new select in that version at least.
$("#ddlReport").parent().hide();
works for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With