RobG wrote:

On Oct 13, 1:34 pm, expresso<dschin...@gmail.com>  wrote:
I don't think it's too hyped.  Having calls to javascript in your
elements defeats the purpose of unobtrusively maintaining and using
libraries like jQuery.

The mechanism frequently used to attach such listeners is to add a
class, id, name or some other attribute value designed to make the
element identifiable specifically to add a listener. How is:

   <div class="mySpecialClass" ...>

hugely different to:

   <div onclick="mySpecialListener()" ...>

when both attributes can be added using exactly the same server logic,
static template or whatever? The only difference is that in the first
case, the client must do extra work to attach listeners that could
have been added on the server directly.

Consider also that in the second case, you don't care about a document
ready or load event, or whether the user must wait for elements to be
"enlivened" while other content loads. Not hip, not cool or funky, but
very robust and avoids a bunch of issues.

Adding listeners at the client simply because the chosen development
library supports it is not a particularly convincing argument.


--
Rob


For one, you're usually using that class to style something too (a class="required" can be used for validation and for styling the input differently to show the user it's a required field), so you use essentially the same markup to hook in both your presentational layer and your behavioural layer.

I've rarely used onclick after discovering the unobtrusive way of doing js, it's easier to maintain and your code looks cleaner.

Jonathan
--
Jonathan Vanherpe - Tallieu & Tallieu NV - jonat...@tnt.be

Reply via email to