From: Gerard Ketuma on
So i have studied the DOM level 2 event handlers and have written some
nifty functions to take care of the browser incompatibilities with
this model. However, I feel like working with the traditional way of
handling events, where we assign functions to the event handler
property, is way easier and makes my code easy to follow. I know there
are all these benefits to using level 2 event handlers, like making
the code modular, making it easier for two or more people to handle
the same event. My question is, which of these models do you
frequently use? and why?

From: RobG on
On Aug 11, 5:21 pm, Gerard Ketuma <gket...(a)gmail.com> wrote:
> So i have studied the DOM level 2 event handlers and have written some
> nifty functions to take care of the browser incompatibilities with
> this model. However, I feel like working with the traditional way of
> handling events, where we assign functions to the event handler
> property, is way easier and makes my code easy to follow. I know there
> are all these benefits to using level 2 event handlers, like making
> the code modular, making it easier for two or more people to handle
> the same event. My question is, which of these models do you
> frequently use? and why?

There is no one way, it depends on the job.

Assigning a function reference to an "on" event property is fine where
an element only has one listener for that event (which is most of the
time). Where an element may have more than one listener for the same
event, then other schemes are required.


--
Rob
From: Richard Maher on

"Gerard Ketuma" <gketuma(a)gmail.com> wrote in message
news:490bd8a4-a678-4cb8-92be-6f752dfcc1b8(a)e15g2000yqo.googlegroups.com...
> So i have studied the DOM level 2 event handlers and have written some
> nifty functions to take care of the browser incompatibilities with
> this model. However, I feel like working with the traditional way of
> handling events, where we assign functions to the event handler
> property, is way easier and makes my code easy to follow. I know there
> are all these benefits to using level 2 event handlers, like making
> the code modular, making it easier for two or more people to handle
> the same event. My question is, which of these models do you
> frequently use? and why?
>

Personally, I don't think you can go past something along the lines of
David Mark's approach.

Cheers Richard Maher


From: Garrett Smith on
On 2010-08-11 06:04 PM, RobG wrote:
> On Aug 11, 5:21 pm, Gerard Ketuma<gket...(a)gmail.com> wrote:
[...]

> There is no one way, it depends on the job.
>
> Assigning a function reference to an "on" event property is fine where
> an element only has one listener for that event (which is most of the
> time). Where an element may have more than one listener for the same
> event, then other schemes are required.
>
I like to use the approach of adding DOM 0 event handler properties when
the script generates the HTML code. In those cases, unrelated features
should not be accessing those elements anyway, and so should not care
about the event handlers.
From: Gerard Ketuma on
> There is no one way, it depends on the job.
>
> Assigning a function reference to an "on" event property is fine where
> an element only has one listener for that event (which is most of the
> time). Where an element may have more than one listener for the same
> event, then other schemes are required.
>
> --
> Rob

Thanks for all the input. makes sense