简体   繁体   中英

Is there an easy way to clone an existing chosen select box?

Able to clone the dropdown with values. It's working fine in the first row but when I click the glyphicon for cloning the another row the dropdown control froze (Nothing happened).

@Html.DropDownList("searchfieldsDropdownList", new SelectList(Model.DataDictionary, "ID", "BLSName"), "", new { @class = "**chosen-select**" })

$("**.chosen-select**").chosen();

$(".glyphicon-plus").click(function () {
    $(this).closest("tr").clone(true).appendTo("#ruleTable");});

在此处输入图片说明

Initialize the plugin on the new select after you insert it

Something like:

$(".glyphicon-plus").click(function () {
   var $row = $(this).closest("tr").clone(true).appendTo("#ruleTable");
   $row.find('.chosen-select').chosen()
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM