I have a (multiple) select in my JQM page.
I need to force option with value ‘A’ de-selection on any other option selection.
HTML is like this:
<select name="select-1" id="select-1" multiple="multiple" data-native-menu="false" />
<option value='A'>a</option>
<option value='B'>b</option>
<option value='C'>c</option>
</select>
I’m using some code like this, with no success… 🙁
$("select#select-1").change(function() {
$("select#select-1").val('A').attr("selected", false).trigger("refresh");
});
It looks like the option I’m trying to de-select is selected, and all others are de-selected (excluded the current one) … 🙁
A jsfiddle is here.
I played around a little bit with your problem and assuming I did not misunderstand your problem (see comments), this snippets works (however probably there are simpler solutions…)
If option with value=’B’ is selected, then option with value=’A’ will be deselected.
EDIT updated now with
$('#select-1').selectmenu('refresh');and it now also works in the jsfiddle