Domanda

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.

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top