JQuery Mobile, select do not show selected option until clicked

I am trying to add <options>

to several <select>

dynamically via ajax, when I add them directly to HTML, it works great, but when I load them in AJAX, they will not display the selected option until <select>

.

I have tried .trigger('create')

for all elements and even .enhanceWithin()

to no avail.

This jsfiddle shows the problem: http://jsfiddle.net/3c01g6e2/1/

Any help please?

+3


source to share


1 answer


From demo page (also see documentation )

If you are manipulating selections via JavaScript, you must call the update method to update the visual style. Here's an example:

var myselect = $("select#foo"); 
myselect[0].selectedIndex = 3;
myselect.selectmenu("refresh");

      



If you add $("select").selectmenu("refresh");

to the end of your violin, it will update correctly. (Updated script)

+2


source







All Articles