Replace browser confirm() with other library like bootbox

66 Views Asked by At

Browser native confirm dialog doesn't look good.
I have ember route wherein taking user confirmation to proceed if there are any unsaved changes. I wanted to change the dialog with bootbox confirm dialog but that doesn't stop the execution as bootbox.confirm() method is async.

        willTransition: function(transition){
            // model dirty checking logic to set flag value
            if(flag){
                if(!confirm("Do you want to leave this page without save?")){
                    transition.abort();
                }
            }
          }

Note: ES6 is not used in project

1

There are 1 best solutions below

1
Quentin On

Since it doesn't block, the only way to do this is to:

  1. Act as if the user said "No" then
  2. If they click "Yes": programmatically restart whatever it was that was cancelled at step 1.