문제

The code is very simple and can be view on jsfiddle.

Basically, whenever I clone something I need to recall the plugin so it can work on the clone. Unfortunately, it duplicates the info.

$(document).on('click', '.add', function(){
    $(".content").append($(".tbl").last().clone());

   // $(".categories").chosen(); this makes duplicate
});

With the line commented it simply does not work.

도움이 되었습니까?

해결책

I'm not sure this is OK for you, but instead of cloning the whole table, you can clone the select itself:

$(document).on('click', '.add', function () {
    var $clone = $(".tbl select").last().clone();
    $(".content").append($clone);
    $clone.chosen();
});

Updated Fiddle

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top