After changing a menu from a regular select to a jQuery selectmenu, I can no longer select options in it programatically. Is there a way to do this?
The code to select
Please note you must use indexes (not values) to select the option using this method.
For instance, given this select.
In this case the expression $('#ListId').selectmenu("value", "value-two");
wouldn't return any result. Instead of that, we have to use $('#ListId').selectmenu("value", "2");
. In other words, we have to use the position/index of the element inside the select. Not the value!
Finding the index is easy though. You can use the following line to achieve it.
var index = $('#ListID option[value="value-two"]').index();
$('#ListId').selectmenu("value", index);