简体   繁体   English

关闭模态后刷新父页面

[英]Refresh parent page after closing modal

When a user opens this modal, they can see their shopping cart information and delete items(other jquery) on the modal. 当用户打开此模式时,他们可以看到他们的购物车信息并删除模态上的项目(其他jquery)。

But how could I refresh the parent page after a user closes up the modal? 但是,如何在用户关闭模式后刷新父页面?

I read several posts but did not find any useful information for my situation. 我读过几篇帖子,但没有找到有关我情况的有用信息。 I know I need to use something like window.location.reload(true); 我知道我需要使用像window.location.reload(true); Where should I put that in the code? 我应该把它放在代码中的哪个位置?

$(function(){

    $('#main').off('click.login').on('click.login',function(){

        $('body').loadmodal({

            id:'cart',
            title:'Shopping Cart',
            url:'/cartDisplay/',
            width: '550px',
        }); 


    });
});

Update 更新

    $(function(){
    $('#main').off('click.login').on('click.login',function(){

        $('body').loadmodal({

            id:'cart',
            title:'Shopping Cart',
            url:'/polls/cartDisplay/',
            width: '550px',

        }); 


    });

    $('#cart').on('hidden', function () {
        window.location.reload(true);
    })

});

Try this. 尝试这个。

  $("#cart").on('hide', function () {
        window.location.reload();
    });

I assume that you are using Twitter Bootstrap 我假设您使用的是Twitter Bootstrap

Bootstrap 3 Bootstrap 3

$('#cart').on('hidden.bs.modal', function () {
    window.location.reload(true);
})

Bootstrap 2.3.2 Bootstrap 2.3.2

$('#cart').on('hidden', function () {
   window.location.reload(true);
})

As far as I can tell, jquery.loadmodal.js has bootstrap.js as a dependency, so its modals are still subject to bootstrap's methods. 据我所知, jquery.loadmodal.jsbootstrap.js作为依赖项,因此其模态仍然受制于bootstrap的方法。

In that case, you can simply bind to hidden.bs.modal 在这种情况下,您可以简单地绑定到hidden.bs.modal

...
$('#yourModal').on('hidden.bs.modal', function () {
    location.reload();
});
...

Where you open the nyroModal window, just add this callback function: 在打开nyroModal窗口的地方,只需添加此回调函数:

 callbacks: {
       afterClose: function() {
              window.location.reload();
            }
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM