Synchronizing Multiple WebDialogs
-
@thomthom said:
Yes - that exact sequence give me an alert box.
Mind you - I tried this in the console.
Bingo! In the console I get the alert. Now maybe I can bury my Kolossal Kludge.
Thanks.
-
Ok - so when communicating with Webdialogs:
- Initialize a Webdialog object.
- Populate with HTML and display the dialog
- Wait for a "ready" signal from the dialog before attempting any communication
This sounds like the check-list you have to follow in order to reliably establish communication? One for your Webdialog gotacha-thread.
-
One thing I've learned is to include a callback at the end of my html telling the script that the WebDialog is ready to receive communication, as you mentioned, and as I have mentioned in other threads.
-
@rickw said:
One thing I've learned is to include a callback at the end of my html telling the script that the WebDialog is ready to receive communication, as you mentioned, and as I have mentioned in other threads.
Precisely, if you need a web dialog the web dialog has to run the show. Anything else is a pas de deux to nowhere.
-
@rickw said:
One thing I've learned is to include a callback at the end of my html telling the script that the WebDialog is ready
I don't understand. Maybe you are solving a different problem. Here's my situation, simplified to a single WebDialog.
User clicks button. (There is no button to click until the <body> is built, so calls from a button click can't happen prematurely - I think.) JS calls Ruby callback requesting data. Ruby fetches data and returns it to JS.
I think the "Ruby, data please" call also implies "Ruby, I'm ready". No? What am I missing?
-
Ah! Didn't notice that the
.show
and.show_modal
where block methods. That's useful to know. Saves that extra callback from the webdialog. -
This gets an alert from a file, at least for me:
wd = UI;;WebDialog.new "foo", true, "", 100, 100, 100, 100, true wd.set_html "<html><body>Hello World</body></html>" wd.show{ wd.execute_script( 'alert( "hello from foo" );' ) }
What problem are you having, exactly?
-
@cjthompson said:
What problem are you having, exactly?
Thomthom didn't have a problem. I did.
The problem was that if you called wd.execute_script() after wd.show() (instead of in a block passed to wd.show() ) it failed.
Thank you for your clear code. Do you happen to know any more about when the show() block is actually executed than what the docs report?
Thanks.
-
not really. I pretty much just stumbled across it, and saw that it worked.
I don't really know much about DOM events or even html in general. Maybe you know how to execute a script that will show what state the browser is in, and execute that on show?
-
@martinrinehart said:
Do you happen to know any more about when the show() block is actually executed than what the docs report?
I assume it would be possible to devise some tests to track when it happens, using a javascript logger or something.
-
@jim said:
I assume it would be possible to devise some tests to track when it happens, using a javascript logger or something.
Jim, this is a sensitive and tender area! My VisMap did not originally support the Mac because of timing/thread issues. The simple answer was to postpone the start of Ruby/JS chat by forcing the user to click an otherwise unnecessary startup button.
If you find a tool that actually lets you step through the states of the browser, it would be invaluable.
-
@martinrinehart said:
If you find a tool that actually lets you step through the states of the browser, it would be invaluable.
... for whom?
"This is commercial, for-profit work. At some point there will be a send-me-money feature added. At this point (mid-summer, 2009) that feature does not exist. The whole price right now is feedback. Tell me what works and what's unclear. Major mistakes and minor typos." [source]
Free content/editing from feedback seems as bad as free designs from competitions (much despised around here - example).
Advertisement