[thelist] javascript default event handlers, default events. [TIP]

Matt Warden mwarden at gmail.com
Wed Aug 31 13:07:27 CDT 2005


Lee,

I think we're going in circles here, so I'll just try to boil it down
to stuff we haven't already covered. See below:

On 8/31/05, Kowalkowski, Lee (ASPIRE) <lee.kowalkowski at hmrcaspire.com> wrote:
> I propose that:
> 
>         <elem id="foobar" onFoo="bar()">
> 
> Is the correct way to separate presentation and behaviour, because this is
> just an interface, the behaviour is not here, where is the behaviour?

bar() is a javascript behavior just as alert() and open() are. You
have JavaScript embedded within your markup. There is no such thing as
an interface in JavaScript (to my knowledge). This is a JavaScript
function, which is a definition of behavior. Further, the "onFoo" part
is also a definition of behavior.

> Where as:
> 
>         document.getElementById("foobar").onFoo = bar;
> 
> Has not separated behaviour and presentation at all, in fact they're more
> coupled now.  I'm explicitly referencing a presentation element, not that I
> think that it can be totally avoided, but we can do this:

There are no presentation elements at all in your example. See my
previous posts.

> Do you see how this is more loosely coupled from a behaviour / presentation
> standpoint?

No.

-- 
Matt Warden
Miami University
Oxford, OH, USA
http://mattwarden.com


This email proudly and graciously contributes to entropy.


More information about the thelist mailing list