Hi Per,
> This was how I wrote it, but it doesn't work:
> Event.observer(window,'mouseup',alert('hi'));
There are a couple of problems with that code. First, you're calling
Event.observer (with an 'r' at the end); the method is Event.observe
(no 'r'). The second problem is that you're calling the alert()
method and then passing its result into the Event.observe call. You
want to pass a reference to a function object to Event.observe
instead. (You can do this in many ways. One common way is to wrap
the code in an anonymous function declaration. For anything of any
size, I recommend named functions instead.)
There are lots of examples of event handlers, with discussion, on the
unofficial Prototype & script.aculo.us wiki:
http://proto-scripty.wikidot.com. Look under "Prototype Tips".
HTH,
--
T.J. Crowder
tj / crowder software / com
On Jan 2, 6:30 pm, Per <[email protected]> wrote:
> Hi,
> I'm new to protocoljs, but it's this thing I'm trying to do, and it
> doesn't work. It drives me mad.
>
> Anyway,
> I try to do this with protocoljs:
> <body onmouseup="alert('hi');">
>
> This was how I wrote it, but it doesn't work:
> Event.observer(window,'mouseup',alert('hi'));
>
> What is the right way to do it?
>
> Thank you!
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---