HTMLDialog #show vs #show_modal and #close

I can create an HTMLDialog box and use UI.start_timer and #close to close it after a period of time.

The HTMLDialog box has a title bar.

Does show_modal create a dialog that has no title bar?

If I use #show_modal, using UI.start_timer and #close won’t close the dialog box.




Yes. Because modal means waiting for user interaction and Ruby will wait to execute the code lines after show_modal line (here UI.start_timer) . Therefor a block inside will not happen. User must close the modal window manually or the dialog itself have to send a callback to Ruby.
Then the code execution continues.

Actually you can close the modal HTMLDialog like:
this will close it after approx 5 sec :wink:

dialog =
UI.start_timer(5) { dialog.close }

while with non modal dialog this will work too:

dialog =
UI.start_timer(5) { dialog.close }
1 Like

Term for today