开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜