PDA

View Full Version : Making MessageBox Synchronous



bvan
15 Jan 2007, 9:24 AM
In my old code, I was using the javascript "confirm" function to ask whether or not the user was sure they wanted to delete a tree node. Now, I want to make use of messageBox confirm, but I can't figure out a way to stop my program from deleting the node before the user clicks Yes or No in the confirm box. In other words, since the messageBox does not return true or false, I can't wrap it in an If statement and halt my delete code from executing. So my question is, how do I use MessageBox synchronously and as a replacement for javascript confirm?

Thanks in advance!

tryanDLS
15 Jan 2007, 9:54 AM
You can't make it sync - the alert/confirm methods interact with the browser differently to do that. You need to specify a callback to handle the response, which doesn't fire until the user does something. Look at the examples http://yui-ext.com/playpen/yui-ext.0.40/examples/dialog/msg-box.js