Dynamically loading select_jquery with Ajax+jqtransform implementation

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.