[thelist] AJAX Tip

Lee kowalkowski lee.kowalkowski at googlemail.com
Thu Apr 6 10:40:02 CDT 2006


On 06/04/06, Christian Heilmann <codepo8 at gmail.com> wrote:
> Why add your code in the markup and mix structure
> and behaviour when you don't have to?

I've said this before, but onlclick="return myFunc(this)" *isn't*
mixing structure and behaviour, as long as the definition of myFunc is
externalised.  However, I admit it *is* mixing markup and *code*.

Doing getElementById('foo') is mixing structure and behaviour. 
However, it's generally unavoidable, but onclick="return myFunc(this)"
is more loosely coupled, in my opinion.

> I know many CMS that allow you to apply a class to a link, but not
> many (good ones that do manage content instead of create web sites)
> that allow you to add own inline event handlers.

I don't blame them!  I wouldn't dream of using a CMS to maintain the
functionality in a website.

> If you want to edit misspellings and get a change request every time
> some content has to change be my guest, I'd rather have an editor with
> a short period of training be able to add something like an image
> popup in a CMS by applying a class or select a plugin than mess around
> with my code.

Separation of content and markup is another thing again!  I don't edit
code to change content either, because it's all externalised using
localisation.  I know CMS systems are limited in this area (and
rightly so).

I'm starting to realise why we're having these discussions, as a web
application developer I forget the majority of people do ordinary,
content-based websites.  They can be totally different beasts. 
Absolutely, when using CMS for maintenance, any form of inline script
is totally unrecommended.

> So, yes, these are generic, but what is the use in bespoke development
> of functionality that needs to be used over and over again anyways?
> How many more menu scripts do we need?

Menu scripts?  *Shudder* (Hate them)  No, I'll give you a real world
example: In our applications we often get requirements to set focus on
the first form field on every page, of course, this is done
unobtrusively, using the DOM, and generically, so it's the exact same
script on every page.

Sorry about the confusion.  *LOL*   Yes, content authors definitely
benefit from separation of content and code, I wouldn't have it any
other way.  Developers benefit from separation of content,
presentation and behaviour (i.e. MVC).  In certain circumstances, I
would view the markup for a form for instance as an interface between
behaviour and presentation.  As long as the content is also
externalised.   That is, I couldn't imagine letting our content
authors maintain form markup when our application heavily depends on
it.

-- LK



More information about the thelist mailing list