Storing data attributes in 'class' vs in HTML5 data-attributes
Can anyone offer an opinion on whether it's better to use the Rails conventions provided in the dom_class
and dom_id
attributes for semantic helpers like div_for
rather than HTML5 data-attributes like 'data-class' or 'data-id'?
ie:
<div id="post_550" class="post">
vs
<div data-class="post" data-id="550开发者_如何学C">
Just one opinion...
- If you're doing css formatting, use div.class.
- But if you're doing javascript stuff, then I think the html5 attributes make sense.
That way, your presentation stuff is one place, and your data stuff another. You can always mix/match too in your selectors if needed.
精彩评论