I agree, then, in your specific case, using the onLoad attribute of the 
body tag will have the same results.  But, there's a (growing) trend in 
client-side programming to try and separate the behavior of a page 
(javascript) from the display of the page (html and css).  Even with 
respect to the display of the page, we have a separation between 
structure (html) and style (css).  I just wanted to make sure you were 
aware of the Event.observe() functionality.  Now that you know it's 
available, you may find the need for it later on.  Plus, it's handy to 
use Event.observe on the window's load event because you know that (a) 
all DOM elements will be available to javascript and (b) that Prototype 
has performed its extensions on Javascript.  Thus, using it can often 
help to avoid some of the errors that can be caused by improperly using 
javascript.

Sebastian Sastre 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to