I need to do multiple file uploads using nested form and jQuery. so I wrote an helper using link_to_function method:
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
this code simply creates a link that, if pressed, renders a new file upload nested form. it surprisingly works, even if I'm using rails3 beta4 (and I know that 'link_to_function' is deprecated)
is there a better way to do the same without using link_to_function or some AJAX call?
thanks in advance ;)