Closing a WebDialog
-
I have an OK button on my WebDialog, and want it to close the dialog.
What is the proper command to close a WebDialog from a button?
-
The answer should be that you use the WebDialog.close method, but that hasn't worked for me. I have tried to close my dialog from a button using two methods:
A). Used WebDialog.add_action_callback to add a callback, which in turn calls WebDialog.close on the WebDialog, and call this callback in the script behind my close button.
B). The script behind my close button uses window.close() in javascript.
Either way, only the html page within the WebDialog seems to be closed. I am left with the dialog window still sitting there, displaying a "This program cannot display the webpage" message.Just to be clear, here is my close button code in HTML:
<input type="button" class="okcancel" value="Cancel" onclick="close_dialog();" />
Here is the javascript that button runs:
function close_dialog() { window.location='skp_close_dialog'; }
Here is where I register my callback that closes the WebDialog (@dialog is the dialog I opened earlier):
@dialog.add_action_callback("close_dialog") { |d,params| @dialog.close }
It seems like it should be pretty simple, but it just doesn't close right. If anybody out there knows why this happens, I'd appreciate hearing about it.
-
Wow, face red! It took me until I'd posted the problem & looked at my reply sitting there that I saw my error. I was missing a colon in my javascript that called the callback ('skp_close_dialog' should be 'skp:close_dialog'). Once I fixed that, the problem went away.
So the answer is, Webdialog.close works just great.
-
Thanks,
I have mine working now as well.
Advertisement