This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Custom Confirm Dialog

 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've managed to create some code that creates a dialog window with an OK button, a choice of 3 images (warn, error, info) and I made it modal using some other semi-transparent divs.

What I'd like to do now is create my own custom confirm dialog that has YES/NO buttons similar to how I've done everything else. I've seen examples on the web, but the ones I have found are commercial so I can't see the code.

What I need to figure out how to do is attach a function handler to the YES/NO buttons and somehow from my function I use to actually create and display the dialog, return true/false from that handler to said function.

I'm a bit out of my league on this though. Any helpful tips?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure if this is what you are asking:

doucment.getElementById("idYes").onclick = functionName1Yes;
doucment.getElementById("idNo").onclick = functionName1No;

eric
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, basically, I have a funtion:



So yesClicked and noClicked return true/false appropriatly, but I really need showConfirm to return that true/false value.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is not going to happen. You are going to have to break your funciotn into two parts since there is no way to make JavaScript sleep. If you would look into an OO JavaScript it would be easier to implement in my eyes.

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic