Question

When a user opens this modal, they can see their shopping cart information and delete items(other jquery) on the modal.

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); 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);
    })

});
Was it helpful?

Solution

Try this.

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

OTHER TIPS

I assume that you are using Twitter Bootstrap

Bootstrap 3

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

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.

In that case, you can simply bind to hidden.bs.modal

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

Where you open the nyroModal window, just add this callback function:

 callbacks: {
       afterClose: function() {
              window.location.reload();
            }
        }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top