Well there's three things that I see:
1. You don't have to put the Event.observe() function call in the
onLoad attribute of the <body> tag. You can put it within a script tag
anywhere in your document, though usually between the <head> tags, as
long as it appears within <script> tags.
2. The second parameter is "load" not "onLoad" as you've done it
below. Usually, the parameters for this function conform to the same
names as the attribute without the "on" in front of them. Thus,
"onClick" becomes simply "click" and "onKeyUp" would be simply "keyup".
3. You shouldn't need the "this" keyword when calling your function as
you're not calling an object's method, just a function you've added to
the page. Unless I'm mistaken about your page structure, I suppose, but
in that case, I'm not sure that "this" will refer to the object you want
it to without using the prototype bind() function, for which you can
find more information online.
To be honest, though, I tend to use an anonymous function with my window
loading observations. In that case, you can do something like this:
Event.observe(window, "load", function() {
/* ... put statements here ... */
});
Instead of defining a function and then using observe() to call it.
That's only my style, though, and doesn't have to be yours. Just wanted
you to know about the option.
- Dash -
Sebastian Sastre wrote:
> Sorry but I have to make a correction. I've had to take back one
> version of the onLoad and call directly the function. I can't figure
> out yet why if I put:
>
> Event.observe(window,"onLoad",this.initializeBrowserView)
>
> in the onLoad() of body the initializeBrowserView function is not
> executed when is supposed to. I've tried some variations onload,
> onLoad, load with same results
>
> cheers,
>
> Sebastian
> PD: first I've have passed in the third argument the string of the
> name of the function, then called the fuction like this
> "this.initializeBrowserView()" which gives an error about js
> conversion failure. Then I've figured out that they need the function
> object to be passed which has a lot more sense than strings or other
> 'creative' things.
>
>
> >
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---