javascript - How create dynamically selectmenu in jQuery Mobile? -
i trying dynamically create select
element, isn't styled jquery mobile. correct way achieve this?
here's working jsfiddle
example: http://jsfiddle.net/gajotres/dexac/
$(document).on('pagebeforeshow', '#index', function(){ // add new select element $('<select>').attr({'name':'select-choice-1','id':'select-choice-1'}).appendto('[data-role="content"]'); $('<option>').attr({'value':'1'}).html('value 1').appendto('#select-choice-1'); $('<option>').attr({'value':'2'}).html('value 2').appendto('#select-choice-1'); // enhance new select element $('select').selectmenu(); });
also take @ article, there find different method of enhancing jquery elements markup, or can found here.
Comments
Post a Comment