Multiple modal bootstrap returning always the same content

0

I'm developing an asp.net mvc application, in one of the pages of the site I call several modals of the bootstrap one on top of the other, however, when already has a modal open the new appears with the same content as the old, follows code snippets.

$('#menuLista').click(function () {
    //$('.modal-container').removeData('bs.modal');
    $.get('@Url.Action("MenuListas")',
    { idE: '@ViewBag.idEvento' },
    function (data) {
        $('#fecharModalEv').click();
        $('#modalMnLista').find('.modal-content:first').html(data);
        $('#modalMnLista').modal({ show: true });
    }).error(function () {
        alert('ocorreu um erro ao abrir  janela');
    });

    $.get(url, function (data) {
        $('.modal-content').html(data);
        $('#modal-container').modal('show');
    });             
}

<div id="modal-container" class="modal fade"
         tabindex="-1" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content"></div>
    </div>
</div>
<div id="modalMnLista" class="modal fade"
         tabindex="-1" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content"></div>
    </div>
</div>

I pasted some snippets here, not containing the script tags, etc.

asked by anonymous 03.07.2015 / 03:04

1 answer

2

You are applying html to all the divs with the class .modal-content in your second ajax: $('.modal-content').html(data);

Try changing

$('.modal-content').html(data);

by

$('#modal-container').find('.modal-content:first').html(data);

on your second get ajax.

    
04.07.2015 / 17:29
Exception p: ajax Unable to attach behavior to non-ClientBehaviorHolder parent Advantages / Disadvantages Magento x Opencart x Other Open eCommerce [closed]