Hi I have dynamically created selectmenu options that populates the drop down correctly. My problem is, on selecting any option(value) from the list of drop down, the value gets overriden with the first value from the list.
Kindly refer this fiddle to understand the problem http://jsfiddle.net/praleedsuvarna/SwLNG/
I had refered to few of the earlier post, but non of them was of much help.
Below is the html code for your reference
<!DOCTYPE html>
<html>
<head>
<title>jQM Complex Demo</title>
<meta name="viewport" content="width=device-width"/>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
</head>
<body>
<div data-role="page" id="checkout">
<div data-id="commonHeader" data-role="header" data-position="fixed">
<a href="#" rel="external" data-direction="reverse" data-rel="back" data-icon="back">Back</a>
<h1>Checkout</h1>
</div>
<div data-role="content">
<label for="state_o">State:</label>
<select name="state_o" id="state_o" data-native-menu="false">
</select>
</div>
<div data-theme="a" data-role="footer" data-position="fixed">
</div>
</div>
</body>
</html>
Following is the java script
$(document).on('pageshow', '#checkout', function(){
var stateList = "";
stateList = stateList + '<option value="Maharashtra">Maharashtra</option>';
stateList = stateList + '<option value="AP">AP</option>';
stateList = stateList + '<option value="MP">MP</option>';
stateList = stateList + '<option value="Delhi">Delhi</option>';
stateList = stateList + '<option value="Goa">Goa</option>';
stateList = stateList + '<option value="Karnataka">Karnataka</option>';
stateList = stateList + '<option value="Gujarat">Gujrat</option>';
stateList = stateList + '<option value="Assam">Assam</option>';
stateList = stateList + '<option value="Bihar">Bihar</option>';
stateList = stateList + '<option value="Haryana">Haryana</option>';
stateList = stateList + '<option value="J&K">J&K</option>';
stateList = stateList + '<option value="Kerala">Kerala</option>';
stateList = stateList + '<option value="Odisha">Odisha</option>';
$("#state_o").html(stateList);
$("#state_o").selectmenu("refresh", true);
});
Any help would be highly appreciated.