what is the equivalent of “data-hover:” in a ruby on rails' link_to block

断了今生、忘了曾经 提交于 2019-12-13 04:39:51

问题


I have the following html

<a href="#" data-hover="Seraglio"><span>Seraglio</span></a>

How do I convert it to RoR ?


回答1:


Syntax:

link_to(body, url, html_options = {})

So for your example, in .erb format:

<%= link_to("#", {"data-hover" => "Seraglio"}) do %>
  <span>Seraglio</span>
<% end %>

Docs: http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to




回答2:


You may do it this way:-

link_to(body, url, :data =>{:hover => your_data_hover_value})



来源:https://stackoverflow.com/questions/19779979/what-is-the-equivalent-of-data-hover-in-a-ruby-on-rails-link-to-block

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!