Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » BrowserWidget, JQuery document.ready and BrowserFunctions
BrowserWidget, JQuery document.ready and BrowserFunctions [message #1067613] Tue, 09 July 2013 14:55 Go to next message
Stefan Milchram is currently offline Stefan MilchramFriend
Messages: 33
Registered: September 2012
Member
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
Re: BrowserWidget, JQuery document.ready and BrowserFunctions [message #1067700 is a reply to message #1067613] Wed, 10 July 2013 07:52 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
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 #1067720 is a reply to message #1067700] Wed, 10 July 2013 09:43 Go to previous messageGo to next message
Stefan Milchram is currently offline Stefan MilchramFriend
Messages: 33
Registered: September 2012
Member
Hi Ivan,

I tried "$(window).load( function (){" instead of $(document).ready( function(){".
It isn't working either. You can check using my snippet i postet here.
Also plain javascript window.onload does not work.
Why are the BrowserFunction's put into place at a different time compared to the SWT-BrowserWidget?
What can i do now to make this work?
Re: BrowserWidget, JQuery document.ready and BrowserFunctions [message #1067905 is a reply to message #1067613] Thu, 11 July 2013 08:06 Go to previous messageGo to next message
Tim Buschtoens is currently offline Tim BuschtoensFriend
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 Go to previous messageGo to next message
Stefan Milchram is currently offline Stefan MilchramFriend
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

Re: BrowserWidget, JQuery document.ready and BrowserFunctions [message #1075617 is a reply to message #1067953] Mon, 29 July 2013 18:59 Go to previous messageGo to next message
Stefan Milchram is currently offline Stefan MilchramFriend
Messages: 33
Registered: September 2012
Member
Thanks to some suggestions from Tim we found the problem (although we do not know why its happening in this case):
Our html containing the calendar script also features a css for printing:
<link rel='stylesheet' type='text/css' href='../fullcalendar/fullcalendar.print.css' media='print' />

When
media='print'
is in place the page never completes loading.
Removing this solved the problem, as we do not want to support printing the calendar in RAP it does not matter.

Thanks for your help.
Re: BrowserWidget, JQuery document.ready and BrowserFunctions [message #1471911 is a reply to message #1075617] Thu, 13 November 2014 12:45 Go to previous messageGo to next message
Phil Wim is currently offline Phil WimFriend
Messages: 89
Registered: October 2013
Member
Hey Stefan,

i'm thinking about an RAP JQuery calendar widget as well. Even if your post is a while ago, how was your experience with it. Did it fulfill your needs?

I tried to download your example. Somehow it's not available anymore. Could you provide it again?

Thanks in advance
Philippe
Re: BrowserWidget, JQuery document.ready and BrowserFunctions [message #1471936 is a reply to message #1471911] Thu, 13 November 2014 13:11 Go to previous messageGo to next message
Aleksander   is currently offline Aleksander Friend
Messages: 44
Registered: May 2014
Location: France
Member
I had no problem downloading it.
Re: BrowserWidget, JQuery document.ready and BrowserFunctions [message #1471938 is a reply to message #1471936] Thu, 13 November 2014 13:15 Go to previous message
Phil Wim is currently offline Phil WimFriend
Messages: 89
Registered: October 2013
Member
Now it works. Before just a blank page. Thanks for pointing me out.
Previous Topic:Drawing combo in workbench
Next Topic:Configuring jetty truststore unsuccessful
Goto Forum:
  


Current Time: Thu Apr 25 10:45:16 GMT 2024

Powered by FUDForum. Page generated in 0.03378 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top