Close one modal and open a new modal with one button

I am using bootstrap and have one that would like to link to the other . I can't figure it out and I'm currently using modal.close()

and .modal('show')

, but it doesn't work.

$('a#to3heart').click(function(){
    $('#portfolioModal2').modal({onShow: function (dialog) {
        $.modal.close()
        $('#portfolioModal1').modal('show'); 
            return false;
        }
    });
});

      

+3


source to share


2 answers


using:

$("#modal1").modal('hide');
$("#modal2").modal('show');

      



see http://getbootstrap.com/javascript/#modals

demo: http://jsfiddle.net/5qCm9/

+2


source


I had a similar problem and solved it with a generic jQuery solution.

It just hides all modals that are not targeted.



$('button[data-target]').click(function () {
    $('.modal').not($(this).data('target')).modal('hide');
});

      

0


source







All Articles