简体   繁体   中英

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

I have the following html

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

How do I convert it to RoR ?

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

You may do it this way:-

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM