这是一个简单的问题,我有点惭愧地问,但是我一直在撞墙并在导轨3文档中导航而没有任何成功:/
所以,这是事情:
当我使用fields_for帮助程序时,它将生成的字段包装在<div class="fields"> ... </div>标记中.
所以,我的代码是
<ul class="block-grid two-up">
<%= f.fields_for :images do |image_builder| %>
<%= render "images/form", :f => image_builder %>
<% end %>
</ul>
Run Code Online (Sandbox Code Playgroud)
生成的html是:
<ul class="block-grid two-up">
<div class="fields">
<div>
<label for="company_images_attributes_0_image"> Image</label>
<input id="company_images_attributes_0_image"
name="company[images_attributes][0][image]" type="file">
</div>
</div>
<div class="fields">
<div>
<label for="company_images_attributes_1_image"> Image</label>
<input id="company_images_attributes_1_image"
name="company[images_attributes][1][image]" type="file">
</div>
</div>
</ul>
Run Code Online (Sandbox Code Playgroud)
我想要做的是将<div class="fields">包装器标签更改为<li>.
文档说您可以将选项传递给fields_for,但是不清楚您可以传递哪些选项,也许您可以更改此包装器标记?
可能是覆盖一个函数,有点像ActionView::Base.field_error_proc表单中的错误.
快速编辑:我忘了提到我正在使用simple_form生成此表单.我尝试在simple_form.rb配置文件中查找自定义方法,但我没有看到任何方法.
解决方案 经过进一步调查后,结果表明表单也使用了nested_form gem来生成表单(不仅仅是simple_form).这个生成器导致fields_for被包装在div标签中.谢谢大家的建议!
我正在尝试pjax我正在开发的应用程序,但我有点撞墙了.
也许我会以错误的方式解决这个问题,让我解释一下.
在应用程序中,我有一个主菜单在顶部,具有不同的部分.此菜单中的每个链接都启用了pjax,这意味着只有应用程序的主体才会更改.
通常,当您单击没有pjax的链接时,将触发document.ready方法.我使用它将事件绑定到按钮,如下例所示.
这是我的users.js.coffee文件
loaded = false;
$ ->
$("#btn_new_user").bind "click", (event) ->
if not loaded
@path = $('#btn_new_user').attr("path")
$("#new-users-container").load(@path)
loaded = true
$("#new-users-container").slideToggle()
Run Code Online (Sandbox Code Playgroud)
正如您在此示例中所看到的,当"用户"页面完成加载时,它将绑定一个带有事件的按钮,该事件将表单加载到div中并对其进行动画处理以显示它.
但是,当我从管理员的其他部分开始并单击"用户"链接以显示此按钮时,该事件不会绑定.当我在"用户"部分重新加载页面时,document.ready触发器和按钮工作正常.
是否有更好的技术将事件绑定到按钮或是否有某种方法可以在pjax上触发document.ready?
谢谢.
hg serve在Windows中使用该命令时,服务器正确启动,但当有人尝试进行克隆时,会出现此错误.
$ hg serve
listening at http://machineX:8000/ (bound to *:8000)
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 4456)
Traceback (most recent call last):
File "SocketServer.pyc", line 558, in process_request_thread
File "SocketServer.pyc", line 320, in finish_request
File "mercurial\hgweb\server.pyc", line 42, in __init__
File "SocketServer.pyc", line 615, in __init__
File "BaseHTTPServer.pyc", line 329, in handle
File "BaseHTTPServer.pyc", line 323, in handle_one_request
File "mercurial\hgweb\server.pyc", line 74, in do_GET
File "mercurial\hgweb\server.pyc", line 65, in do_POST
File "mercurial\hgweb\server.pyc", line 58, in …