Hi, I use it like this:

function foo(id) {
    alert($(id).innerHTML);
}
function bar(id) {
    alert($(id));
}
Event.observe(window, 'load', function() {
    Event.observe('element_id', 'mouseout', function() {
        foo('element_id');
        bar('element_id');
    });
});

I have tested this code and it works great, also it looks like yours.
Hope it works for you too.

On Wed, 14 Nov 2007 03:18:49 -0800
Vladimir Ghetau <[EMAIL PROTECTED]> wrote:

> 
> Hey guys,
> 
> 
> Thanks for stopping by, and checking out my problem.
> 
> The idea was generally speaking , sorry about the braketing issue.
> Imagine that function would really work.
> 
> To reword the issue:
> 
> - I am attaching the event to the *active* window of the browser,
> right?
> - The file that contains the script, is remotelly accessed by the
> browser, it's a JS file.
> 
> The code I attached was an example, of how the behaviour, should look.
> Let's ignore those sintax errors for now, my point was: why isn't the
> script attaching the event, even if there's a proof that the JS file
> has been loaded (the fact that when hovering the element is calling
> the foo function) until the page loads completely all its elements
> (images/css files/extra JS files).
> 
> So, if I let the  page load completely, everything works, the foo/bar
> was an abstract example. If the page is not loaded, the observers are
> still "sticked" to the active page, however, the called functions
> aren't recognized, even if they are stored inside the same file which
> triggers the "onload" event.
> 
> That's the quick story, any opinions?
> 
> Thanks,
> Vladimir Ghetau
> http://www.Vladimirated.com
> 
> On Nov 14, 9:31 am, "Andreas Franke" <[EMAIL PROTECTED]> wrote:
> > 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 Ghetauhttp://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
> -~----------~----~----~----~------~----~------~--~---
> 


-- 
Julio Carlos Menéndez
GNU/Linux User #403551
http://deltha.uh.cu/~juliocarlos

Attachment: signature.asc
Description: PGP signature

Reply via email to