user3369592
user3369592

Reputation: 1447

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.

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

});

Upvotes: 11

Views: 72884

Answers (4)

nullwriter
nullwriter

Reputation: 804

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

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

Upvotes: 0

Prateek Sharma
Prateek Sharma

Reputation: 269

Try this.

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

Upvotes: 16

solvease
solvease

Reputation: 539

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

Upvotes: 14

couzzi
couzzi

Reputation: 6366

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

Upvotes: 5

Related Questions