How can I prevent a script from executing after BootstrapDialog has started?

I am using BootstrapDialog to display some warnings.

    BootstrapDialog.alert({
          type:  BootstrapDialog.TYPE_DANGER,
          title: 'Oops! ',
          message: 'Error, occured',
          buttons: [{
              label: 'Ok'

          }]
      });
    window.location.replace("http://example.com");

      

I want to prevent it from being redirected to another page when opening a dialog. It should only redirect if the user clicks the OK button, as if I were using an alert in javascript.

+3


source to share


1 answer


You have to attach the code window.location

inside the attribute buttons

. Try this:



BootstrapDialog.show({
    type:  BootstrapDialog.TYPE_DANGER,
    title: 'Oops! ',
    message: 'Error, occured',
    buttons: [{
        label: 'Ok',
        action: function(dialog) {
            window.location.replace("http://example.com");
        }
    }]
});

      

+2


source







All Articles