mardi 22 mars 2016

Select2 - is duplicating when i use clone function

I have seen this question jQuery Select2 duplicating, but not work for me.

When i click in plus button this function running

$("#novo-insumo").click(function(){
        var novoID = $(".insumo-row").length;

        var elementCloned = $("#insumo-row")
                .clone();
        elementCloned.find('#insumo-select0').attr('id', "insumo-select" + novoID);

        $("#insumo-tbody")
            .find("select")
            // call destroy to revert the changes made by Select2
            .select2("destroy")
            .end()
            .append(
                elementCloned

        );
        // enable Select2 on the select elements
        $("#insumo-tbody").find("select").select2({
            placeholder: "digite",
            "language": {
               "noResults": function(){
                   return "Nenhum resultado encontrado";
               }
            }
        });




    });

But the result not is that i want.

Form

I'm using select2-4.0.2 version.

Aucun commentaire:

Enregistrer un commentaire