Allow to start a plugin just once
-
I'm wondering, that I can't find a nice solution, to allow to start a plugin just once.
So, with the help of my plugin, I start a WebDialog... How I can ask, if there is the same WebDialog already opened?
I think, this should be very easy, but, sorry...
I tried:
if (!defined? dlg) dlg = UI::WebDialog.... else dlg.bring_to_front
But with this version, I am able to start several WebDialogs...
Thanks for your help!
-
Assuming your code is wrapped inside a method inside a module... then referring to the web-dialog like this will use the same object IF it already exists, and if it doesn't it makes a new one...
@dlg = UI::WebDialog.new(...) unless @dlg
Then later use@dlg
to change its url, show it etc, and set/reset all other options available etc... -
Sometimes, it is so easy!
Thanks TIG!!
-
@tig said:
Then later use
@dlg
to change its url, show it etc, and set/reset all other options available etc...This is important!
The dialog instance is not destroyed when you close it. You can re-open it again.
And if you had data from the dialog, stored in Ruby vars, you can reset them back into the dialog's Javascript vars, after it reopens.
Advertisement