I am making a jQuery Mobile and PhoneGap app. I am dynamically loading a select menu’s options. I want the first option to be the default “value” of my select menu. After appending, I have all my options, but none of them is already chosen. I tried refreshing and setting value attribute, but it doesn’t work. Here is my javascript:
function customerList(data)
{
var html ='';
console.log('Start');
$.each(data, function(key, value){
html += '<option value="'+ data[key].id + '">' + data[key].label + '</option>';
$('#customer').append($(html));
html='';
});
$('#customer').selectmenu();
}
Setting
will work