Marcos Vinicius
Marcos Vinicius

Reputation: 207

I need to recreate the multiselect after ajax response

I need to recreate the multiselect in "Local" after "Empresa" ajax response with this data response. I put the information in "Local" select but I am not able to recreate the "Local" multiselect.

$.ajax({
    url: '/ajaxrequests/requestlocals',
    type: 'POST', dataType: 'json',
    data: {empresas:empresas},
    success: function(retorno){
        console.log(retorno);
        $('#ajax_local').html("");
        $.each(retorno, function (valor, chave) {
            $('#ajax_local').append($('<option>', {
                value: valor,
                text : chave
            }));
        });
        $('#ajax_local').multiselect();
    }
});

Imagem 1 Imagem 2

Upvotes: 0

Views: 682

Answers (1)

Emre Kabaoglu
Emre Kabaoglu

Reputation: 13146

Try to destroy it first;

$("#ajax_local").multiselect('destroy');
$("#ajax_local").multiselect();

Upvotes: 1

Related Questions