3 Replies Latest reply on Nov 26, 2012 8:39 AM by Paul Masters

    confirm always performs callback

    Paul Masters

      When you use a confirm dialog the callback always gets called even if you press the cancel button.


      confirm('Do you really want to quit?', asl.exit);


      This always quits the app.


      From the documentation it appears that the callback should only for when you press ok to confirm.

      Is this a bug?


      Is there another way to see which button was pressed?

          • Re: confirm always performs callback
            Benedict Kennedy

            Hi Paul,


            I'm very sorry, I completely missed this question. Yes the confirm callback is always fired, this is because we cant replicate the blocking feature of the native JavaScript confirm. The missing information you need is that the callback has a boolean argument so that you can tell whether OK or Cancel has been pressed. So the code you are looking for is:


            confirm('Do you really want to quit?', confirmCallback);
            function confirmCallback(isOk) {
                      if(isOk) {
                      else {
                                //Ignore, cancel pressed


            I'm sorry for the delay, and also the developer guide as it doesn't mention this argument. I shall get the team to update it.


            Best regards,