I have a question, it’s not the clearest but I wanted to see if anyone might have some ideas on it!
I’m working on an app, currently we only have one theme but in the future we will have many different ones, so this question’s been on my mind a lot….
If you start off with clean HTML, and are just adding elements for styling purposes, is it ok to use jQuery to add extra elements? I think adding things this way makes it much easier to make adaptable layouts, and keeps your code cleaner and easier to understand, but I’ve always heard it’s bad practice.
I use this system for quickly mocking up the files and it is so much faster than sorting through stacks of files and functions and classes to add this markup.
What are some examples of alternative systems for adding this sort of markup besides trudging through tons of code? Maybe with the example of making a static two column layout flexible, or making a sliding doors button throughout the site…if anyone wants to take a stab at it you can also use forms as an example (something that for me has been tricky in terms of advanced styling)…and, heaven forbid, making it all switch to a right to left language layout!
Hopefully some font-end developers can sort of understand my question of wanting to keep my styling markup vs. functional markup separate. I appreciate any thoughts/suggestions/tutorials anyone can recommend!
Thanks!
That’s pretty much the way jQuery Mobile does it’s formatting.
You need to put an attribute or two on an element (or nothing for basic elements) and then when your jQM page is about to be rendered jQM comes along and adds heaps of classes to the elements formatting it to suit.
Bad Practice – No!
Good Practice, probably especially if you intend your themes to be radically different
Should probably add that some minimal ‘fixed’ styling would help those who chose to turn off javascript.