behaviors, modular units of Javascript code that
can be associated with elements in a web page
chosen with CSS selectors.
The library is based on Ben Nolan's Behaviour.js,
but with a slightly different design. The library of
CSS selectors was written by Simon Willison.
I'm releasing this under the LGPL. Ben's original
library is released under a BSD license. Both of
our libraries rely on Simon's
getElementsBySelector function, which doesn't
seem to be under any license.
HTML and Javascript: Don't Cross the
Streams [ 1]
Dynamic HTML (DHTML) enables programmers
to use Javascript to modify the style, contents, or
interactive behavior of the elements of a web
page. In particular, programmers can attach
event handlers to document elements, which
respond to user actions with programmable
behavior. The easiest way to do this is to specify
an event handler property directly in the HTML:
...
As proponents of unobtrusive Javascript pointout, there are problems with writing web pages
this way. For one thing, it mingles two unrelated
pieces of the web page: the document's structure
(represented by the HTML code), and its behavior
(represented by the Javascript). It makes it difficult
to split the task among different developers, say,
a programmer and a graphic designer. And it
results in a monolithic structure that's hard to
understand and maintain. Aspect-oriented
programmers call this the problem of tangling.
Another problem with this code is that such web
pages end up with bits of conceptually related
Javascript code strewn about the web page. For
example, if all div elements with the class clickable
are supposed to respond to the onclick event in
the same way, the programmer shouldn't have
to copy the same code in the onclick property of
each such element in the web page. Aspect-
oriented programmers call this problem
No comments:
Post a Comment