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_frontBut 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@dlgto 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
@dlgto 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.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement