【问题标题】:How to completely hide bootstrap modal after getting ajax response获得ajax响应后如何完全隐藏引导模式
【发布时间】:2014-11-13 20:17:41
【问题描述】:
// From Ctp
hcp_btn.on('click', function(){
    var value = hcp_field.val();
        if(value != '')
        {
            $.ajax(
            {
                type: 'POST',
                url: ajax_url+'users/add_hcp_type/'+value,
                success:function(response)
                {
                    if(response == 'exist')
                    {
                        $("#hcp_error").show();
                        hcp_btn.addClass('disabled');
                    }
                    else{
                        $("#hcp_type_modal").modal('hide');
                        $("#hcp_type").html(response);
                    }
                }
            });
        }
    });

// For Controller
$this->autoRender = false;
$this->layout = 'ajax';
$this->viewPath = 'Elements';
$this->render('hcp_types');


![This type of background left after modal close in ajax success function][1]

我正在使用 cakephp 并使用 ajax 渲染元素并在 ctp 中动态加载数据。但是在 ajax 成功函数中获得 ajax 响应后,我试图关闭引导模式 nut modal 没有完全关闭一些透明背景。

【问题讨论】:

    标签: ajax twitter-bootstrap cakephp response


    【解决方案1】:

    用这个来清理左边的背景

    //when hidden
    $('#hcp_type_modal').on('hidden.bs.modal', function(e) {
     $('.modal-backdrop').remove(); 
    });
    

    【讨论】:

    • 我必须将此代码放在哪里...在我的元素中或在呈现元素的 ctp 中或在此之后 $("#hcp_type_modal").modal('hide');
    • 可以放在ajax开始前
    • 正如你所建议的,我将代码放在 ajax 开始之前.. 在 $.ajax() 函数之前,但问题仍然存在..
    • 放在hcp_btn.on('click', function(){之前
    • 不工作...问题仍然存在
    猜你喜欢
    • 1970-01-01
    • 2016-04-04
    • 1970-01-01
    • 2019-01-06
    • 1970-01-01
    • 2018-04-27
    • 1970-01-01
    • 2021-02-16
    • 1970-01-01
    相关资源
    最近更新 更多