Home » Eclipse Projects » Remote Application Platform (RAP) » BrowserWidget, JQuery document.ready and BrowserFunctions
|
Re: BrowserWidget, JQuery document.ready and BrowserFunctions [message #1067700 is a reply to message #1067613] |
Wed, 10 July 2013 07:52 |
Ivan Furnadjiev Messages: 2427 Registered: July 2009 Location: Sofia, Bulgaria |
Senior Member |
|
|
Hi Stefan,
BrowserFuction is attached to the client document in the document
"onload" event. According to JQuery documentation the .ready() function
is not compatible with body onload event (see [1]). You could try the
JQuery .load() function instead as suggested in the documentation.
[1] http://api.jquery.com/ready/
HTH,
Ivan
On 7/9/2013 5:55 PM, Stefan M wrote:
> Hi,
>
> We use a jquery-based calendar script wrapped by a BrowserWidget in RCP.
> When we tried it in RAP it didn't work.
> The reason is that the calendar script calls a BrowserFunction in the document.ready like this:
>
>
> $(document).ready(function () {
> theJavaFunction();
> });
>
> But at this time "theJavaFunction", which is a SWT-BrowserFunction is not yet available. When i call it later, like when i click a button, it works fine.
>
> I wrote a small snippet to reproduce the error, its attached to this post.
> Should i file a bug?
> Is there a workaround?
>
> Thanks in advance,
> Stefan
--
Ivan Furnadjiev
Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/
Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
|
|
| |
Re: BrowserWidget, JQuery document.ready and BrowserFunctions [message #1067905 is a reply to message #1067613] |
Thu, 11 July 2013 08:06 |
Tim Buschtoens Messages: 396 Registered: July 2009 |
Senior Member |
|
|
Hi.
The problem here, I think, is that both your script and RAP try to do
something on the load event. RAP attaches the browserFunctions, your
script calls them. But since your script runs inside the iframe it's
called first. SWT/RCP does has better control over the browser widget
and can probably make sure it's notified first. To fix this, simply put
your code in a timeout:
$(document).ready(function () {
window.setTimeout( callTheJavaFunction, 0 );
});
Greetings,
Tim
Am 09.07.2013 16:55, schrieb Stefan M:
> Hi,
>
> We use a jquery-based calendar script wrapped by a BrowserWidget in RCP.
> When we tried it in RAP it didn't work.
> The reason is that the calendar script calls a BrowserFunction in the document.ready like this:
>
>
> $(document).ready(function () {
> theJavaFunction();
> });
>
> But at this time "theJavaFunction", which is a SWT-BrowserFunction is not yet available. When i call it later, like when i click a button, it works fine.
>
> I wrote a small snippet to reproduce the error, its attached to this post.
> Should i file a bug?
> Is there a workaround?
>
> Thanks in advance,
> Stefan
>
--
Tim Buschtöns
Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/
Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
|
|
|
Re: BrowserWidget, JQuery document.ready and BrowserFunctions [message #1067953 is a reply to message #1067905] |
Thu, 11 July 2013 12:18 |
Stefan Milchram Messages: 33 Registered: September 2012 |
Member |
|
|
I tried the aproach with "window.setTimeout(..." in my snippet, it worked there.
When i tried the same with our calendar-integration in our application it did not work, i get the same error as before. I checked also with higher timeouts (up to 10 secs), the BrowserFunction is not defined.
I created a snippet-plugin and put the same html and js - files in as we use in our application. There it works.
I cant see any difference, can you give me some hints where i can debug to see why the BrowserFunction is not defined in the client?
Thanks for your help
[Updated on: Thu, 11 July 2013 12:18] Report message to a moderator
|
|
| | | | |
Goto Forum:
Current Time: Mon Sep 23 04:07:35 GMT 2024
Powered by FUDForum. Page generated in 0.03804 seconds
|