I am currently working on improving the way I mark up different components in HTML that are parsed by a jQuery script and generated when the page loads.
For instance, right now I can insert the following code into my page:
<a href="link.html" class="Theme-Button Theme-Button-Style-win2007 Theme-Button-iconLeft Theme-Button-AlignmentCenter Theme-Button-fullWidth">This is a button</a>
Once the jQuery script locates it, it will add the necessary HTML to create a button with an icon and handle all required events.
However, this method feels messy and involves lengthy class names. I would prefer something like this instead:
<a href="#" class="Theme-Button" data="{style: 'win2007', icon: 'left', align:'center', fullWidth: true}"></a>
It may not be significantly shorter, but it seems cleaner to me and requires less parsing effort. My concern is that after looking into "expandos," I fear some browsers may not support it and it could lead to validation issues.
Does anyone have any better suggestions for how to approach this?