0

I'm using a JavaScript library that calls window.confirm. The default browser dialog is pretty ugly so I'd like to override it by using the a Bootstrap themed confirmation dialog from the Bootbox library.

I can hook up the override to show the Bootbox confirm dialog but cannot get the response returned based on the user selection into the custom dialog. In the following case I need to call window._(true | false).

Here's the closest I've got. Any ideas?

        function consume_confirm() {
        if (window._confirm) return;

        window._confirm = window.confirm;

        window.confirm = function (message) {
            var answer;
            bootbox.confirm(message, function (result) {
                answer = result;
            });
            return answer;
        };
    }
amphetamachine
  • 27,620
  • 12
  • 60
  • 72
Stuart Hallows
  • 8,795
  • 5
  • 45
  • 57
  • Sorry, that isn't possible. No matter how you do it, if you try to `return answer` it will be `undefined` or whatever you set it to when you declared it. – Kevin B Apr 03 '14 at 14:57
  • You can't just return it. The best thing would be to just use the callback which you are already using (bootbox.confirm). Let that handle the logic that you would have the containing code perform. – KJ Price Apr 03 '14 at 15:07

0 Answers0