close one modal and open a new modal with one butt

2019-04-01 01:06发布

I am using bootstrap and have a one modal that I would like to have a link on to another modal. I can't seem to figure this out and currently I am using the modal.close()and .modal('show') but that is not working.

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

2条回答
可以哭但决不认输i
2楼-- · 2019-04-01 02:00

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

It just hides all modal that are not targeted.

$('button[data-target]').click(function () {
    $('.modal').not($(this).data('target')).modal('hide');
});
查看更多
Luminary・发光体
3楼-- · 2019-04-01 02:02

use:

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

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

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

查看更多
登录 后发表回答