Today, at work, I encountered a problem, the company name in the page is selected after the project name with Ajax read out. But Jqtransform is called after the page is loaded, so the Company name dropdown box is not able to show the most recent data.
</SCRIPT>
With Firebug can see the data has actually been stitching up, but form has been in the page after loading has been called Jqtransform method, Jqtransformselectwrapper inside the UL data has not been updated. Think for a long time decided to use a simple and rude way to update the UL.
function Companyajax (proid) {
$.ajax ({
Type: "POST",
URL: "${pagecontext.request.contextpath}/recordsearch/ajax/getcompanyajax.do",
DataType: "JSON",
Data:{proid:proid},
Success:function (Jsondata) {
var tmp= ';
tmp+= ' <select id= "Centerid" name= "Centerid" onchange= "Comchange ()" style= "width:160px;" Name= "Centerid" > ";
$ ("#centerid"). empty (); tmp+= ' <option value= ' ">--please choose--</option> ';"
for (Var i=0;i<jsondata.length;i++) {
tmp+= ' <option value= ' ' +jsondata[i].centerid+ ' > ' +jsondata[i].centername+ ' </option> ';
}
tmp+= ' </select> ';
$ ("#centerid"). Parent (). remove ();
$ ("#comLable"). After (TMP);
$ ("#centerid"). Jqtransselect ();
}
});
}
Haha, after the AJAX query company data, the jqtransform generated select related div deleted, and then the SELCT splicing, and then reinitialize the select. method is more stupid, but first use it, there will be a better way to say.
Isn't it cool? Haha, in fact, or jqtransform compared to the force, small partners need to use similar effects, you can refer to the following.