link_to不格式化按钮 [英] link_to not formatting button

查看:165
本文介绍了link_to不格式化按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站上使用rails和jquery mobile.要创建按钮样式的链接,我必须添加特定信息,例如:

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>

要在Rails中做到这一点,我应该像这样使用link_to:

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!

推荐答案

尝试

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

不同的原因在这里说明: http://apidock.com/rails/v3.0.0/ActionView/Helpers /UrlHelper/link_to

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

这篇关于link_to不格式化按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆