The scenario:
- A homepage that is generated with PHP and a template engine.
- The page is being redesigned.
- The new design is based on jQuery UI.
- The current CMS uses multiple templates: a page template, an article details template, a comments template etc.
The problem:
Some templates (like the article details template) generate html fragments that should use jQuery UI elements like tabs. Currently the data source of the page template does not contain any information which elements should be turned into jQuery UI elements in the main jQuery call in the documents head.
Possible solution
Add a CSS class like “jqTabs” to the html markup of the sub-templates and use the selector .jqTabs in the main jQuery script.
Question
Is this a bad idea?
BTW: “Use a different CMS” is not a valid answer, because this is not an option right now (deadline, budget,… you name it -.- ).
Not a bad idea at all.
That is one of the primary uses of classes.
A class (like and ID) can be used as both a way to style an element and / or a hook for scripting.
In this case, it might be the best possible solution, as it allows for what seems to be minimal markup changes for a wider redesign.
And it is easily reversible.