The radconfirm function has the following function signature according to the documentation:
radconfirm(text, callBackFn, oWidth, oHeight, callerObj, oTitle)
And the callback function that's passed as parameter callBackFn in the above signature has a function signature of:
confirmCallBackFn(arg)
The Arg parameter is described as being True if the user clicks OK and False if the user clicks Cancel (should actually be true and false -- little "T" and little "F", but I digress).
My main question: what happens to callerObj parameter defined in the radconfirm function signature? Shouldn't it be passed into the confirmCallBackFn as a parameter (e.g. the function signature should change to be confirmCallBackFn(arg, callerObj))? This would be very convenient as I could then abstract away the calling of the confirmation dialog somewhere else and pass into my convenience function the function that should run on confirmation. E.g.:
function doConfirm(message, title, functionToCallOnConfirm) { radconfirm(message, onConfirmCallback, null, null, funtionToCallOnConfirm, title); }; function onConfirmCallback(arg, callerObj) { if (arg) callerObj(); }
Then, where I need the confirmation dialog in my client app, I can simply do:
function somethingThatRequiresConfirmation() { doConfirm("message", "title", doSomething); } function doSomething() { // Code to do something }
This is nice because every developer on the team doesn't have to concern themselves with how the confirmation dialog works. They just call the doConfirm function with their text, pass their worker function and they're done.
Secondary, and very minor question: Isn't there a better way than completely overriding the dialog template to change the text on the buttons? The documentation indicates the text is "Yes" and "No," however, in practice (at least with the "WebBlue" skin) the text is actually "OK" and "Cancel" mimicking the undesirable behavior of the default javascript confirm function.