Jeelig
Jeelig

Reputation: 102

jQuery mobile change select value by script fail (nothing happens)

I'm desperately trying to change the option value in of a select at pageshow and it does nothing. I don't know how to change it

<select name="sliderAutoConnect" id="sliderAutoConnect" data-role="slider">
      <option value="1">Off</option>
      <option value="2">On</option>
</select>

and the script :

$("#sliderAutoConnect option[value=2]").attr('selected', 'selected');
$('#sliderAutoConnect').selectmenu('refresh');

Upvotes: 0

Views: 493

Answers (1)

codaniel
codaniel

Reputation: 5253

You need to refresh the slider widget instead of selectmenu. Try this instead:

$('#sliderAutoConnect').slider('refresh');

Everything else worked for me when i tested it. I just changed that one line.

Upvotes: 1

Related Questions