cordova - Preselected value not showing in jquery mobile -
i have screen dropdown dynamically populated database. use phonegap , jquery mobile. values added dropdown 1 of values should pre-selected. problem is, when screen shows, there no selected value in field (image 1). when open dropdown, pre-selected value highlighted (image 2). use jquery 1.8.3 , jquery mobile 1.2.0.
image 1:
image 2:
here code:
selectsubjectssuccess: function(tx, results){ var len = results.rows.length; var selval = -1; console.log('### szlog: subjects found: ' + len); var subjects = '<option value="">' + sz.langdata['subject'] + '</option>'; var pre_subject = $('p.plannerfield #subject').data('preselect'); (var = 0; < len; i++){ subjects += '<option value="' + results.rows.item(i).sj_id + '"'; if(pre_subject == results.rows.item(i).sj_id){ subjects += ' selected="selected"'; } subjects += '>' + results.rows.item(i).sj_name + '</option>'; } var sdd = $(".subjectdropdown"); sdd.empty().append(subjects); sdd.selectmenu(); sdd.selectmenu("refresh", true); }
thanks in advance!
for preselecting value in dropdown in jquery use
<script> $('#user_tb3 option[value='+ "{{ids}}" +']').attr('selected', 'selected'); </script>
write in body select control ending work {{ids}} replace value of dropdown definately work @bbasmer luck
Comments
Post a Comment