Issue 62: Suggestion: Move javascript functions calls out of inline event  
handlers and into jQuery selectors
http://code.google.com/p/django-hotclub/issues/detail?id=62

New issue report by [EMAIL PROTECTED]:
Since Pinax uses the jQuery framework, it seems like it might as well take
advantage of the "selector" philosophy of jQuery, which allows you to bind
javascript code via CSS-style selectors and thus cleanly separate
javascript code from html.

So, for example, instead of this:

templates/blogs/edit.html:
<a href="#" onclick="$('#teaser').toggle(); return false;">{% trans
"Teaser" %}</a>

You could do:

templates/blogs/edit.html:
<a href="#" class="teaser-control">{% trans "Teaser" %}</a>

site-media/base.js:
$('.teaser-control').click(
   $('#teaser').toggle();
   return false;
);

That's pretty basic and is just an example; there are even better ways to
generalize this kind of function (where you click on one element to
show/hide a related element).

The advantage of this approach is that all of your application javascript
code finds a home in a single file, as opposed to being spread throughout
your templates, much the way all of the site's styles are in base.css.

Not sure if there is a reason to using inline event handlers, but I thought
I would make this suggestion regardless.


Issue attributes:
        Status: New
        Owner: ----
        Labels: Type-Defect Priority-Medium

-- 
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to