What an incredibly helpful and in-depth answer. Thank you TJC, my
confidence is restored

foob

On May 21, 3:18 pm, "T.J. Crowder" <t...@crowdersoftware.com> wrote:
> Hi,
>
> It's best to actually paste in the code you're having trouble with;
> for obvious reasons, a lot of people won't follow links, and in any
> case, it's just a few lines of code.
>
> The test.js code is:
> * * * *
> Event.observe(window, 'load', function() {
>
>     $('zarks').observe('click', function(e) {
>         Event.stop(e);
>         new Ajax.Updater('view', '/ajax_prototest', {
>             method: 'get',
>             parameters: {id:
> event.findElement('li').readAttribute('id')},
>         });
>     });
>
> });
>
> * * * *
>
> The problem with line 7 is that you're using `event` to refer to the
> event object, but the variable name you used in the function is `e`,
> not `event`, so `event` is undefined. So why is it defined on Chrome?
> It has to do with Microsoft. :-) Instead of passing the event into
> event handlers, IE makes the current event available as a property of
> the `window` object, `window.event`. And of course, you can leave off
> the `window.` prefix when referring to `window` properties, so just
> plain `event` resolves to `window.event`. Chrome tries to be as
> compatible as possible and does both (passing it in and making it a
> property of `window`). So on Chrome, `event` resolves to the event
> object that way.
>
> One of the things Prototype does is smooth out that difference; you
> can (and should) always use the event object passed into the event
> handler; Prototype makes sure it's there for you.
>
> So on line 7, just change `event` to `e`.
>
> A couple of off-topic notes:
>
> * If you like, you can also change `Event.stop(e);` to `e.stop();`
>
> * The ID attribute is reflected by the `id` property on elemeents, so
> you can use `.id` instead of `.readAttribute('id')`.
>
> * You're hooking your event handler using the window onload event.
> That happens at the very, very end of the page load, after all images
> have downloaded, etc. I wouldn't be surprised if people are trying to
> click 'zarks' before it happens. You might look at using dom:loaded
> instead:
>
> document.observe("dom:loaded", your_function_here);
>
> dom:loaded happens as soon as possible, much earlier than window
> onload.
>
> HTH,
> --
> T.J. Crowder
> Independent Software Consultant
> tj / crowder software / comwww.crowdersoftware.com
>
> On May 20, 3:35 pm, foobarmus <foobar...@gmail.com> wrote:
>
>
>
>
>
> > I get an error "event is not defined... test.js Line:7" when clicking
> > the list items inside the orange box 
> > athttp://zark.skagos.com.au/prototype_ff3_ubuntu_test
>
> > The code works in all my other browsers including Chrome/Ubuntu.
>
> > I thought the lowercase 'e' on event might have been the issue, but if
> > I change it to Event, I get "Node is undefined... prototype.js Line:
> > 5366" in all my browsers, including Chrome/Ubuntu and the maccy ones.
>
> > The lowercase 'e' comes from some sample code in the API docs, so I'm
> > sure it's meant to work like that, but FF3/Ubuntu seems to have issues
> > with it.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Prototype & script.aculo.us" group.
> > To post to this group, send email to 
> > prototype-scriptacul...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > prototype-scriptaculous+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/prototype-scriptaculous?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Prototype & script.aculo.us" group.
> To post to this group, send email to prototype-scriptacul...@googlegroups.com.
> To unsubscribe from this group, send email to 
> prototype-scriptaculous+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/prototype-scriptaculous?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to