:) 

-----Original Message-----
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Dan G. Switzer, II
Sent: Monday, April 16, 2007 8:34 AM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: New to jQuery and struggling


>You should be able to use jQuery inline, but you might want to ask 
>yourself WHY you want to use it inline. The power of jQuery is that it 
>can affect EVERY part of the document from just one spot. I'd recommend 
>rethinking your code so as to remove the need for inline JS.

While that is generally the best practice, there are exceptions for every
rule. The one place I do use inline JavaScript is when I'm leverage jQuery
for server-side component helpers (for example, Custom Tags in CF.) 

In this case, my jQuery code is generally outputted after the DOM element is
created. While not ideal, it makes it much easier to encapsulate all my code
into one helper function in my server-side code.

Having all your JS business logic in one place, definitely makes debugging
and modifying code easier, but there are times when inline code makes sense.

-Dan 

PS - This really isn't addressed to Andy, just a general note. Sometimes we
developers get too stuck on following "golden rules" and we end up making
our code harder to work with. So if you find you have to go to long lengths
to code a corner case to a golden rule, just always think if the end pay off
is worth it. Ok, don't with my mini-rant. ;)


Reply via email to