Chapter 16.5. CSS, JavaScript, and Widgets

Widgets are designed to have JavaScript behaviors and element IDs and classes built right into their template code. So, for simple JavaScript and CSS styling that may be all you need. But whenever you do anything slightly more complex, your widget may need access to JavaScript libraries, like MochiKit, Scriptaculous, or Dojo. Widgets provide a simple syntax to assure that the right script and CSS tags get added to your headers, and that they are only added once—even if multiple widgets ask for them.

The functions that do all of this are JSLink and CSSLink. When you display any widget on a page, its CSS and JavaScript links get thrown into a couple of set-like objects that contain only one of each CSS ...

Get Rapid Web Applications with TurboGears: Using Python to Create Ajax-Powered Sites now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.