question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Call confirmAlert box from another confirmAlert

See original GitHub issue

First off, I have been loving confirmAlert and use it all over in my app so thank you.

Right now, I am trying to open a confirmAlert box upon a user clicking a button in a prior confirmAlert box (which should close). However, the second confirmAlert box doesn’t open, probably because the first one is still exiting the DOM.

I see there’s a callback function for willUnmount() (which doesn’t work for triggering the second confirmAlert, probably because the first confirmAlert hasn’t quite unmounted yet) but if there were a callback for afterClose() or something, then I could use that for opening the second one. Is this a feature that will be supported?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ben-pritchardcommented, Sep 9, 2021

Yes if you’re using state in your setConfirmAbort() function then you could be right. You could try with a member variable like I did and/or add some console.log()s to see when confirmAbort actually gets set, maybe adding in some async/await in there if you really need to use state.

1reaction
ben-pritchardcommented, Sep 8, 2021

@mdodge-ecgrow, here is how I’ve used it (I wasn’t using the customUI but it should work the same):

confirmAlert({
  title: 'Confirm remove comment',
  message: "Are you sure you want to abort this batch?",
  buttons: [
    {label: 'No', onClick: () => this.didUserConfirmAbort = false},
    {label: 'Yes', onClick: () => this.didUserConfirmAbort = true},
  ],
  afterClose: () => {this.didUserConfirmAbort && this.removeCommentForRealz()}
 });

Then in this.removeCommentForRealz() you can call another confirmAlert(). Hope that helps!

Read more comments on GitHub >

github_iconTop Results From Across the Web

jQuery : How to call another function on confirm box return value
I am using sweet alert plugin, may be getting problem from that. My confirm function is given below. function confirm(title) { var returnType...
Read more >
Window confirm() Method - W3Schools
The confirm() method displays a dialog box with a message, an OK button, and a Cancel button. The confirm() method returns true if...
Read more >
JavaScript confirm alert box: fancy and simple with 5 online ...
A confirm alert is a type of alert box where a user is asked before taking a certain action. A simple JavaScript confirm...
Read more >
JavaScript Message Boxes: alert(), confirm(), prompt()
JavaScript Message Boxes: alert(), confirm(), prompt(). JavaScript provides built-in global functions to display popup message boxes for different purposes.
Read more >
Window.confirm() - Web APIs - MDN Web Docs
confirm () instructs the browser to display a dialog with an optional message, and to wait until the user either confirms or cancels...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found