how call onLoad() script

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

how call onLoad() script

Sabine Manaa
Hi

I use JQUILayout.
(In my app, on the left is a menu, in the center different pages depending on the menu selection).

For opening a certain page in the center, after clicking in the menu, I make something like:

html << (html jQuery: #center) html: theView.

This opens and renders the page -> ok.

But it does not perform the onLoad() script of theView.

If I force the same page to reload, the onLoad() (Stg+F5), then fires.

I think I should send something to theView and need a hint for this.
Sabine
Reply | Threaded
Open this post in threaded view
|

Re: how call onLoad() script

Paul DeBruicker
Hi Sabine,

Try:

$(theView).filter('script').each(function () {
   $.globalEval(this.text || this.textContent || this.innerHTML || '');
});

after theView is loaded into #center=

It iterates over the HTML in theView inst var and executes the scripts

Good luck

Paul



On 07/04/2013 07:00 AM, Sabine Knöfel wrote:

> Hi
>
> I use JQUILayout.
> (In my app, on the left is a menu, in the center different pages depending
> on the menu selection).
>
> For opening a certain page in the center, after clicking in the menu, I make
> something like:
>
> html << (html jQuery: #center) html: theView.
>
> This opens and renders the page -> ok.
>
> But it does not perform the onLoad() script of theView.
>
> If I force the same page to reload, the onLoad() (Stg+F5), then fires.
>
> I think I should send something to theView and need a hint for this.
> Sabine
>
>
>
> --
> View this message in context: http://forum.world.st/how-call-onLoad-script-tp4697350.html
> Sent from the Seaside General mailing list archive at Nabble.com.
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: how call onLoad() script

Karsten Kusche
In reply to this post by Sabine Manaa
Sabine,

as you're using jQuery, you shouldn't need to use onLoad(). Instead use the jQuery function like so:

jQuery(function(){
// on load code here
});

The function that's passed as parameter to jQuery() is executed when the page is ready (like onLoad) or when you load more html, then it's executed when that html is ready.

In Seaside you can use the html-document's #addLoadScript: method, which will call the jQuery function as long as you use the JQScriptGenerator. See WAWelcome class>>initialize on how to tell your application to use that script generator.

To add a load script, do something like:
 html document addLoadScript: (…)
or  
 html div script: (..).
The later can be a bit tricky though as it overrides the script's ID.

Kind Regards
Karsten


-- 
Karsten Kusche - Dipl. Inf. (FH) - [hidden email]
Georg Heeg eK - Köthen
Handelsregister: Amtsgericht Dortmund A 12812 

Am Donnerstag, 4. Juli 2013 um 16:00 schrieb Sabine Knöfel:

Hi

I use JQUILayout.
(In my app, on the left is a menu, in the center different pages depending
on the menu selection).

For opening a certain page in the center, after clicking in the menu, I make
something like:

html << (html jQuery: #center) html: theView.

This opens and renders the page -> ok.

But it does not perform the onLoad() script of theView.

If I force the same page to reload, the onLoad() (Stg+F5), then fires.

I think I should send something to theView and need a hint for this.
Sabine



--
Sent from the Seaside General mailing list archive at Nabble.com.
_______________________________________________
seaside mailing list


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: how call onLoad() script

Sabine Manaa
Hi Paul and Karsten,

thanks. I have the solution now, yesterday I was on the wrong way and my question was "wrong".

Explanation:
I had already defined the load script within my main pages renderContentOn:
html document addLoadScript: 'labelinside();'.
That works fine if I LOAD the page.

Yesterday I was wrong in assuming that the labelinside() script should execute if I call
html << (html jQuery: #center) html: theView.
Because this does NOT load the whole page and so, the on load is NOT called...this is clear now and this was my error yesterday.

It works if I call the funktion like that:.

        html << (html jQuery: #center) html: theView.
        html add: (JSStream new
                nextPutAll: 'labelinside';
                yourself).

Sabine