Dave
Dave

Reputation: 1500

How to reload page after bootstrap modal closed

$("#customerAdded").modal("show").on("shown.bs.modal", function () {
                window.setTimeout(function () {
                    $("#customerAdded").modal("hide");
                }, 5000);
                location.reload();                  
            });

Ok, it works. But with location.reload(), despite I change the time, the page is reloaded immediately. I would, after modal closed, that the page was reloaded according the time specified.

Upvotes: 0

Views: 9842

Answers (3)

Jakir Hossain
Jakir Hossain

Reputation: 2517

$("#customerAdded").modal("hide").on("hidden.bs.modal", function () {        
        location.reload();                   
});

Upvotes: 1

berkyl
berkyl

Reputation: 426

You could just fire the location.reload() when you hide your modal:

$("#customerAdded")
.modal("show")
.on("shown.bs.modal", function () {
    window.setTimeout(function () {
        $("#customerAdded").modal("hide");
        location.reload(); 
    }, 5000);                 
});

Upvotes: 3

Mitul
Mitul

Reputation: 3437

Here is the code

$('#customerAdded').on('hidden', function () {
    location.reload();
})

Upvotes: 0

Related Questions