Sebastian,
David is suggesting that instead of using
<body onload="functionName();">
to initiate your initial call to kick everything off that you place a
<script language="javascript" type="text/javascript">
Event.observe(window,"load",functionName);
</script>
Block at the bottom of your HTML stream being sent to the browser.
This will cause prototype to register functionName against the
window.onLoadevent.
Event.observe(window,"load",...); can be used multiple times, *before* the
stream has completed.
Ie: once the browser has the complete stream, the window load event will
have fired and the Event observers will not fire again for that page.
Does this make things any clearer?
On 6/12/07, Sebastian Sastre <[EMAIL PROTECTED]> wrote:
>
>
> Hi David,
>
> I think I understand what you mean, but I'm not creatively adding
> *stuff* to the body section. The root component of the Seaside
> application adds for me this one call of this function that I've named
> #initializeViews. Is the only one thing that onLoad does, and it only
> starts this browser views framework I'm making. Everything else is a
> mere consequence of adequately reacting to observed events between
> this views instances as you properly suggested.
>
> Cheers,
>
> Sebastian
>
> On 11 jun, 18:24, David Dashifen Kees <[EMAIL PROTECTED]> wrote:
> > Alternately, to avoid having to add information to the <body> tag, you
> > could use the Event.observe() function of prototype to get the same
> > functionality:
> >
> > Event.observe(window, "load", function() {
> > /* ... do onload functions here ... */
> > });
> >
> > Or, if you have everything you need to do within a function already --
> > we'll call it init() -- you could do this:
> >
> > Event.observe(window, "load", init);
> >
> > which avoids the need for the anonymous function. Really, the two
> > methods are roughly equivalent if you only have one function to call at
> > the start of every page. But, if you ever need to call this function
> > and that one a page loads, the Event.observe() function can be used
> > twice and both functions will be called, but the onload attribute of the
> > body makes this a little more difficult. 'Course, if you're an
> > enthusiast for unobtrusive javascript, the Event.observe() function is
> > probably already your best friend.
> >
> > - Dash -
> >
> > Sebastian Sastre wrote:
> > > OK, figured out now. Was happening to me some sort of loading time/
> > > loading order problem.
> > > For the record I've suggested a recomendation from a seasider of
> > > ensuring order and preventing any transident time invocation. Once
> > > things are settled enough all seems to behave as expected.
> > > I hope this help on future references,
> > > cheers,
> >
> > > Sebastian
> > > PD: the solution was based on using onLoad of the <body> (not any
> > > other) section to call a function that basically initializes
> everything
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---