Trie this, I think it schould work:
Event.observe( window,
"load",
function(){
Event.observe (
'element_id',
'mouseout',
function(){
foo('element_id');
bar('element_id');
}
).bindAsEventListener(this);
}
).bindAsEventListener(this);
There where some trouble with your braces in the code you posted.
An your main-Prob of your code was the "scope"-thing, I think.
Andreas
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[EMAIL PROTECTED] Im Auftrag von Vladimir
Ghetau
Gesendet: Mittwoch, 14. November 2007 03:18
An: Ruby on Rails: Spinoffs
Betreff: [Rails-spinoffs] Event.observe(window, 'load', function) issue
Hi everyone,
I've seen prototype being featured on many sites/blogs, books, and I'm
happy to give it a try. I believe it's a great JS framework. Thanks to
all contributors:)
Now, my problem is, I'm trying to attach an even when my window loads,
to an element inside my page.
The code goes like this:
<script>
Event.observe(window, 'load', function() {
Event.observe('element_id', 'mouseout', function() {
foo('element_id');
bar('element_id');
});
}
</script>
The problem is, I am declaring the foo() and bar() functions way
before calling this window.onload observer, but still when I hover my
mouse over the 'element_id' before my remote JS script loads, I get an
error (Firefox) saying foo() function doesn't exist.
On the other hand, if everything loads on the page, the error doesn't
show up anymore.
I know there has to be a solution out there, and it's just a simple
workaround, but I didn't find it so far.
The other thing that makes me think it's a strange problem, is the
fact that:
- functions are declared before this event
- if the error shows up, it means the event has been attached to the
page
So, based on this info, why I can't get the mouseout effect over the
divs until the remote JS file loads?
As a workaround, I was thinking to show a "loading" image with a text
saying "please wait... your page is loading". When everything is
loaded (css/js files) this message dissapears, and the page is shown,
however, this isn't what I'm looking for.
Thanks,
Vladimir Ghetau
http://www.Vladimirated.com
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---