2

HTML

<a href="#modal-2" role="button" class="btn" data-toggle="modal">Modal with animation</a>

<div id="modal-2" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h3 id="myModalLabel">Modal header</h3>
            </div>
            <div class="modal-body">
                <p>One fine body…&lt;/p>
            </div>
            <div class="modal-footer">
                <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
                <button class="btn btn-primary"  id="book" >Save changes</button>
            </div>
        </div>

我使用了流动的 JS,但没有结果

 $('#book').click(function(e) {
       $.ajax({
            url: base_url+"admin/login/",
            type: "get",
            data: {Name:name, Mobile:mobile},
            success: function( strData ){
                //$('.modal, .modal-backdrop').hide();
                $("#modal-2").modal('hide');

            },
            error: function(){
                $('#report').text('Sorry, Please try again').css('color', 'red');
            }
        });
    });

在这里,我想在单击保存按钮后在回调中调用 ajax 函数。然后在ajax成功后我想关闭引导框弹出窗口

4

2 回答 2

1

如果你要使用 BootBox,你可以这样做:

bootbox.dialog({
        message: "Your Message Here - You can pass in an HTML string",
        title: "Your Title",
        onEscape: function () {
            bootbox.hideAll();
        },
        buttons: {
            danger: {
                label: "Cancel",
                className: "btn default",
                callback: function () {
                    bootbox.hideAll();
                }
            },
            success: {
                label: "Add",
                className: "btn blue",
                callback: function () {

        //Add functionality here

        // Then close the model using
        bootbox.hideAll();

                }
            }
        }
    });
于 2014-02-27T18:06:51.097 回答
0

在ajax定义中你应该使用参数

async : false

您可能必须在模态窗口的主体内使用自定义按钮,而不是来自 bootbox

于 2014-10-15T13:05:29.637 回答