- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
我正在尝试将一个类应用到 Rails 3 中由 button_to 生成的表单。
:class
选项设置提交按钮的类,因此 docs告诉我们使用 :form_class
将类应用于表单。
例如
<%= button_to 'x', user_contact_path(@user, contact), :method => :delete, :form_class => "delete" %>
这只是将属性 form_class="delete"
添加到按钮元素。我已经使用 :html_options
等尝试了各种组合。
有人知道怎么做吗?
最佳答案
这种方法对我来说非常有效。我能够做到:
<%= button_to "Hello", root_url, :method => :get, :form_class => "my_class" %>
以上生成以下内容:
<form action="http://localhost:3000/" class="my_class" method="get">
<div><input type="submit" value="Hello"></div>
</form>
但是,这是在 Rails 3.1 中作为您问题点中的链接,并且自 form class is hard coded 以来在 Rails 3.0.x 中同样不起作用。 .
来自 url_helper 代码:
("<form method=\"#{form_method}\" action=\"#{html_escape(url)}\"
#{"data-remote=\"true\"" if remote} class=\"button_to\"><div>" +
method_tag + tag("input", html_options) + request_token_tag +
"</div></form>"
).html_safe
关于ruby-on-rails - 将类添加到生成的表单的正确 button_to 语法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9295929/
我注意到 button_to 有一个奇怪的行为。我有一些程式化的按钮。当 button_to 生成时,输入提交字段被放置在按钮元素内。最终发生的是单击按钮的内边缘不会将用户重定向到新页面。用户被迫直接
我目前正在使用 link_to: 'btn' do %> Edit Webcast 但我想对 button_to 做同样的事情,但是 button_to 必须有一个传递给它的第一个标签
我使用此代码允许用户向另一个用户发送邮件: 这给了我以下 html: 还有这位电子邮件之王: 我尝试使用 &body 设置邮件正文,但它不
我试图通过按钮的 onclick 方法调用一个函数。这是代码: "show_back(), return false" %> 但它不起作用,每次我单击按钮时都会出现错误 "没有响应 29
似乎 :class 控制的是父表单的类,而不是按钮本身。 我想将 btn primary 类添加到按钮。 如果我不能直接做,我可以使用表单类和SASS来做吗? (使用@extend 或类似的东西)?
我的代码: 'submit', :class => 'submit'} , {}%> 我想这样结束: 但我得到的是: 如何设置类? 最佳答案 HTML 选项是根据 the documentati
查看此问题演变的更新 在我的网站上,每个用户都有一个仪表板,他/她可以在其中单击一个链接来接受或拒绝请求。根据单击的内容,请求记录随后会使用相关状态进行修补。为了让用户更轻松,我试图将此仪表板嵌入到发
目前,我使用以下代码将params [:id]传递给line_items创建 但是,它会将id参数附加在我不希望button_to进行的url查询上。我想要的是通过隐藏的表单字段传递id参数。我可以
这很愚蠢,但我只是不知道如何设置由Rails button_to创建的输入元素的样式-是的,我已经一遍又一遍地阅读文档并尝试了示例。 这是我的ERB代码: 这将产生以下HTML:
我实现了一个基于 ajax 的按钮,用于在用户的“愿望列表”中添加和删除日历事件。该按钮充当切换开关。如果该事件已在他们的愿望 list 上,则会将其删除;如果没有,则会添加它。 我的问题是,当页面首
一直在尝试设计我的 button_to按钮,但是没有运气。我查看了 CSS 文件并使用了 #button {color:red;} , button {color:red;}和 .button {co
在我看来有这个按钮: 'pages', :action => 'yes', :id => p.id, remote: true}, {class: "yes_button"} %> 在 .css 中
我需要提交并保存一些数据。我需要表单中的一些帖子 ID: def message_post_collection_params params.require(:message_post).pe
我在使用 button_to 设置 Bootstrap 按钮组的样式时遇到了问题。 如上所示,我希望在底部有类似的东西,但目前我在使用“button_to”助手时遇到“4”按钮的问题。 我的代码是这样
我正在尝试将一个类应用到 Rails 3 中由 button_to 生成的表单。 :class 选项设置提交按钮的类,因此 docs告诉我们使用 :form_class 将类应用于表单。 例如 :d
我目前正在使用 ruby on rails 3 中的表单。所以在我的项目表单中,我有一个按钮可以让用户退出该项目。然而,奇怪的是,button_to 标签关闭了我的整个表单,我不能再使用我的提交按
基本上,我试图从 rails button_to 获取下拉按钮,这是通过 ajax 完成的,当有人点击该按钮时,它显示渲染的购物车 通过 ajax 渲染标记。 自举: rails button_t
在我的 Rails 3.2.3 应用程序中,我使用 Ajax 和 jQuery。页面上有一个链接,我想用一个按钮替换它。下面的代码运行完美 "home", :action => "test_meth
编写我的第一个非常简单的 Rails 应用程序,一个简单的管理应用程序,用于跟踪我们一个部门的工作。为人们生成的索引页面上有一个 link_to 来添加一个新人。我试图将其更改为 button_to
我在我的 Rails 应用程序中使用 Bootstrap,我想创建一个按钮组,其中包含一个使用 生成的按钮. 这是我的: "), project_steps_path(@proje
我是一名优秀的程序员,十分优秀!