Conditionally setting CSS style from ruby controller

前端 未结 5 1591
没有蜡笔的小新
没有蜡笔的小新 2021-02-01 11:07

I\'m trying to dynamically change (if it got clicked) a normal table header (which is a link) to another defined CSS class \'th.hilite\'. This link simply sorts this column and

5条回答
  •  一个人的身影
    2021-02-01 11:37

    Javascript or jquery is not required..

    The following HAML will work

    %th{:class=>('title' == @sortby)?'hilite':""}= link_to  'Movie Title', movies_path(:sort => 'title'), :id => 'title_header'
    

提交回复
热议问题