I have a table of names. They are ordered randomly. I would like to highlight the name which has the latest created_at value by adding a class to its table row. So far I came up with creating an invisible column with hidden created_at values and then jQuerying the needed row, but it doesn't sound so good.
我有一张名字表。他们是随机订购的。我想通过向其表行添加一个类来突出显示具有最新created_at值的名称。到目前为止,我想出了一个隐藏的created_at值创建一个不可见的列,然后jQuerying所需的行,但它听起来不太好。
A better solution, perhaps?
也许是更好的解决方案?
Edit 1: actually, I would like to highlight the latest added entry for a certain amount of time, ideally only after the name was added. On the next reload/visit all of the rows have to be identically styled.
编辑1:实际上,我想在一段时间内突出显示最新添加的条目,理想情况下,只有在添加名称之后。在下次重新加载/访问时,所有行必须具有相同的样式。
1 个解决方案
#1
1
What about adding a data attribute to each row with the created_at value and then jQuerying the needed row?
如何使用created_at值为每一行添加数据属性然后j查询所需的行?
<tr data-created-at="#{<%= object.created_at %>}">...</tr>
That way you don't need an additional invisible column, hope this helps
这样你就不需要额外的隐形列,希望这会有所帮助
#1
1
What about adding a data attribute to each row with the created_at value and then jQuerying the needed row?
如何使用created_at值为每一行添加数据属性然后j查询所需的行?
<tr data-created-at="#{<%= object.created_at %>}">...</tr>
That way you don't need an additional invisible column, hope this helps
这样你就不需要额外的隐形列,希望这会有所帮助