$("#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.
$("#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.
Share Improve this question edited Jun 17, 2015 at 9:36 Dave asked Jun 17, 2015 at 9:11 DaveDave 1,5125 gold badges31 silver badges49 bronze badges 1- window.setTimeout is executing asynchronically. You should put location.reload() in the window.setTimeout method after $("#customerAdded").modal("hide"); – Martin Kostovski Commented Jun 17, 2015 at 9:20
3 Answers
Reset to default 3You 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);
});
$("#customerAdded").modal("hide").on("hidden.bs.modal", function () {
location.reload();
});
Here is the code
$('#customerAdded').on('hidden', function () {
location.reload();
})