我需要使用嵌套窗体和jQuery做多个文件上传。所以我写了使用link_to_function方法的帮手:渲染部分使用ujs和没有AJAX调用的轨道上3
def add_document_link(title, form)
link_to_function title do |page|
form.fields_for :documents, Document.new, :child_index => Time.now.to_i do |f|
page << "$('#documents').append('#{escape_javascript(render('/realties/document', :f => f))}');"
end
end
end
这个代码只需创建一个链接,如果压制,呈现一个新的文件上传嵌套形式。它出奇作品,即使我用Rails3中BETA4(我知道“link_to_function”已过时)
是有更好的方法做同样不使用link_to_function或一些AJAX调用?
在此先感谢;)
编辑:根据本: http://github.com/rails/prototype_legacy_helper 似乎link_to_function是早在导轨上。不知道它是暂时的还是永久的:| – 2010-06-19 14:03:40