link_to not formatting button

蹲街弑〆低调 提交于 2019-12-23 04:54:09

问题


I use rails and jquery mobile for my site. To create a button styled link, I have to do add specific info, like this:

<a href="user/login" data-role="button" data-theme="a">login</a>

To do this in Rails, I should use the link_to like this:

<%= link_to 'Login', :controller => "user", :action => "login", "data-icon" => "button", "data-theme" => "a" %>

But this is not working, it shows as a normal link. When I look in the code it looks like this:

<a href="/user/login?data-icon=button&amp;data-theme=a" class="ui-link">Login</a>

Any ideas why this happens? Thanks!


回答1:


Try

<%= link_to 'Login', {:controller => "user", :action => "login"}, {"data-icon" => "button", "data-theme" => "a"} %>

The reason this is different is explained here: http://apidock.com/rails/v3.0.0/ActionView/Helpers/UrlHelper/link_to



来源:https://stackoverflow.com/questions/4406702/link-to-not-formatting-button

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