link_to not formatting button
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&data-theme=a" class="ui-link">Login</a>
Any ideas why this happens? Thanks!
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
精彩评论