在一些非表单页面上,我有几个链接,看起来像按钮,而不是超链接...
我以为Butto而不是link会管用,但Butto似乎总是被当作帖子.
有没有一种简单的方法可以简单地用按钮替换(非提交)链接?
在一些非表单页面上,我有几个链接,看起来像按钮,而不是超链接...
我以为Butto而不是link会管用,但Butto似乎总是被当作帖子.
有没有一种简单的方法可以简单地用按钮替换(非提交)链接?
你所要做的就是在你的按钮_的末尾加上一个:method => "get"
,让它像一个链接一样被对待
使用users_path
<%= button_to "BUTTON: link version", users_path, :method => "get" %>
或者,你可以使用cleaner(从网页设计的Angular 来看)方法,实际上只是将链接的样式设置成一个按钮,而不是将表单插入到html中(button_to就是这样做的)
这里有一段代码,实际上只需要处理边框、填充和背景图像
a.button {
background: transparent url('bg_button_a.gif') no-repeat scroll top right;
color: #444;
display: block;
float: left;
font: normal 12px arial, sans-serif;
height: 24px;
margin-right: 6px;
padding-right: 18px; /* sliding doors padding */
text-decoration: none;
}
代码来自上面的链接.无论你 Select 哪种方法都会很好,尽情享受吧!