点击'sweetAlert'警告'ok'后如何调用bootstrap模式?

时间:2016-10-22 05:50:00

标签: javascript jquery twitter-bootstrap alert sweetalert

我想点击sweetAlert警报上的“确定”按钮后调用引导模式。

因此,用户点击OK提醒后的sweetAlert按钮。它会自动调用bootstrap模态。我在javascript中尝试了下面的代码,但没有奏效。

BOOTSTRAP MODAL

<div class="modal fade" id="change_password" role="dialog">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
            </div>
            <div class="modal-body change_password">
            </div>
        </div>
    </div>
</div>

JS CODE

<script language='javascript'>
    swal({
        title: 'Sample Title',
        text: 'Hi',
        type: 'success',
        allowOutsideClick: true,
        html: true
    },
    function () {
        $('#change_password').modal('show');
    });
</script>

1 个答案:

答案 0 :(得分:1)

您的代码运行正常

&#13;
&#13;
swal({
    title: 'Sample Title',
    text: 'Hi',
    type: 'success',
    allowOutsideClick: true,
    html: true
},
function () {
    $('#change_password').modal('show');
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="modal fade" id="change_password" role="dialog">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
            </div>
            <div class="modal-body change_password">
                Modal body
            </div>
        </div>
    </div>
</div>
&#13;
&#13;
&#13;