File_field_tag and rjs

Hello

Is it possible to add and remove file_field_tags on the fly on a form
using only rails code and rjs?

If so can someone provide a solution.

Pawel Jur wrote:

Hello

Is it possible to add and remove file_field_tags on the fly on a form
using only rails code and rjs?

If so can someone provide a solution.

If you just want to add a new input,
then simply increment a session variable or something

% _file_fields.rhtml

<%= link_to_remote(“Add new input”, :action => “add_new_input”) %>

% _file_field.rhtml

<%= file_field_tag(“file[@file_number]”) %>

% file_controller.rb

def add_new_input
session[:file_number] ||= 0
session[:file_number] += 1
@file_number = session[:file_number]
end

% add_new_input.rjs
page.insert_html :bottom, “file_field_div”, :partial => “file_field”

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs