javascript - Jquery/Jquerymobile populate <select> dynamically - ERROR -


i've database containing options add dynamically, after button click, in <select> tag. html looks like, inside div data-role="page" (for jquerymobile)

<div id="endsessionpagecontent" data-role="content">   <div data-role='fieldcontain' id="endsessionform">   </div> </div> 

basically, values sqlite database, , i'd put them inside "endsessionform" div. data should displayed both <inputs> , <select> elements. function looks (no sql interaction here, simplicity):

function buildpage(divid){   $("#endsessionform").empty();   var div = "<div><label>aaa</label><input></input></div>";   div += "<div><label>bbb</label><input></input></div>";   div += "<div><select><option>1</option><option>2</option><option>3</option></select></div>";   $('#endsessionform').append(div);   $("#endsessionform").trigger('create'); } 

then after event, call buildpage function (see jsfiddle live example http://jsfiddle.net/xdr43/12/). trigger(create) used force ui reload:

as can see, <select> not created. jsfiddle page throws error:

syntax error, unrecognized expression: :nth-child  

while, same code in app throws error:

'undefined' not object (evaluating 'this.list[0].appendchild')  

what think wrong? help, hope gave informations need. if need more, ask , i'll add em.

thanks again, best regards

______edit________

this entire function:

function buildpage(divid){   $(divid).empty();   for(var = 0; < results.rows.length; i++){   var area = results.rows.item(i).area;   var campo = results.rows.item(i).campo;   var campowospcs = campo.replace(/ /g,"_");   var valori = results.rows.item(i).valori;   var div = "<div><label for='newcompany_"+campowospcs+"'>"+campo+":</label>"; if(valori == ""){   //input   div += "<input type='text' name='"+campowospcs+"' id='newcompany_"+campowospcs+"' placeholder='"+campo+"'></input>"; }else{  //select           div += "<select name='"+campowospcs+"' multiple='multiple' id='newcompany_"+campowospcs+"'><option>select "+campo+"</option>";   var split = valori.split(";");   for(var j = 0; j < (split.length -1); j++ ){         div += "<option>"+split[j]+"</option>";   }   div += "</select>";     }     div += "</div>"; $(divid).append(div);//alert(div);   }   $(divid).append(div);   $(divid).trigger('create');    } 


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -