1

The issue of substituting one’s own ‘alert’ by contriving a jQuery dialog has been debated previously, for instance here :

Custom alert and confirm box in jquery

In that thread Hemant Malpote objected rightly: « But it [the proposed jQuery dialog-based solution] doesn't block the code. [where]As statement[s] after [a Javascript] alert get execute[d] only when 'Ok' [is] press[ed] ». (Letters or words inside brackets were added by me for the sake of clarity.) I should add that this can wholly change the behaviour of a chunk of code.

How can I design a jQuery dialog so that it behaves the way the Javascript alert does, i.e. stops executing until a dismissal button gets pressed ?

7
  • 1
    think differently and wrap whatever you need to execute in a promise callback and resolve that promise with dialog button Commented May 15, 2016 at 14:38
  • You can use sweet alert at here limonte.github.io/sweetalert2 Commented May 15, 2016 at 14:40
  • Thanks to charlietfl and Fil. I have heard about SweetAlert and am going to give it a go. Commented May 15, 2016 at 15:08
  • @Fil — I have just tested SweetAlert, not thourougly, I confess. Implementing their test code junk —swal({ title: "Error!", text: "Here's my error message!", type: "error", confirmButtonText: "Cool" });— in my own code shows that their 'alert' behaves exactly as a jQuery dialog. Am I missing something? Any clue? Commented May 15, 2016 at 15:34
  • 1
    @charlietfl — I think that is the right thing to do —and I did so—, at least as far as my specific problem needed to be solved: the deferring device works smoothly, is easy to implement and apparently sports many extended possibilities. Cheers ! Commented May 17, 2016 at 4:50

1 Answer 1

2

You can't.

The closest you can come is to cancel whatever triggered it entirely, and then start something new (but similar to what you canceled) when the button is clicked.

Sign up to request clarification or add additional context in comments.

2 Comments

Please see my reply to charlietfl. Though you are quite right, the deferring device is a good workaround.
@BriceCoustillas — That's more or less what this answer is suggesting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.