关闭打开模态后如何打开新模态

时间:2015-03-05 14:13:07

标签: jquery html5 twitter-bootstrap twitter-bootstrap-3 bootstrap-modal

我正在使用bootstrap 3.2.0。 我有一个带3个按钮的模态的场景。每个按钮都会打开一个新的独特模态。但我想这样,如果我点击3个按钮中的任何一个,打开模态(带有3个按钮的那个)应该关闭并打开新模态。模态不是莫代尔。

1 个答案:

答案 0 :(得分:1)

使用BS模态事件:hidden.bs.modal并使用jQuery one()处理它:

[编辑] @cvrebert 对答案发表评论的建议)

// 'next-modal' is one of three buttons inside first modal:
$('.next-modal').click(function () {
    // hide current modal and when it's hidden, open another:
    $('#myModal').one('hidden.bs.modal', function (e) {
        $('#nextModal').modal('show');
    }).modal('hide');
});

DEMO