mochalygin
mochalygin

Reputation: 742

stop execution of JS on bootbox.alert() opening

I had such code:

alert('Error!');
window.location.reload();

It shows alert first and after closing of this alert page will be reloaded;

I want to use bootboxjs for bootstrap, and change my code:

bootbox.alert('Error!');
window.location.reload();

But it don't wait while alert will be closed by user and reloading page right after alert showing. How to fix this?

Upvotes: 1

Views: 2046

Answers (1)

antyrat
antyrat

Reputation: 27765

You need to use callback for this:

bootbox.alert('Error!', function() {
    window.location.reload();
});

look at official documentation

Upvotes: 3

Related Questions