Frage

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.

War es hilfreich?

Lösung

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top