I''d like to achieve something that is better described by the following code: <%= start_form_tag :action => ''create'' %> <%= text_area ''place'', ''description'', :cols => 100, :rows => 4 %> <div id="categories"> <%= form_remote_tag :update => ''categories'', :url => { :action => ''add_category'' } %> <%= text_field_tag ''new_price'' %> <%= submit_tag ''Add'' %> </div> <%= submit_tag "Create" %> <% end_form_tag %> But I know for sure that this isn''t going to work due to the nested use of forms. Is there a Rails-way to submit using AJAX while filling a simple form? Cheers, Marco -- Posted via http://www.ruby-forum.com/.
Marco Lazzeri wrote:> I''d like to achieve something that is better described by the following > code: > > <%= start_form_tag :action => ''create'' %> > <%= text_area ''place'', ''description'', :cols => 100, :rows => 4 %> > > <div id="categories"> > <%= form_remote_tag :update => ''categories'', > :url => { :action => ''add_category'' } %> > <%= text_field_tag ''new_price'' %> > <%= submit_tag ''Add'' %> > </div> > > <%= submit_tag "Create" %> > <% end_form_tag %> > > But I know for sure that this isn''t going to work due to the nested use > of forms. Is there a Rails-way to submit using AJAX while filling a > simple form?Yes, check out submit_to_remote and link_to_remote, particularly their :submit options: http://api.rubyonrails.com/classes/ActionView/Helpers/PrototypeHelper.html#M000412 -- We develop, watch us RoR, in numbers too big to ignore.
Apparently Analagous Threads
- Ajax "Waiting..." flash while round-tripping
- Form helpers don''t work with facade columns?
- Redirect whole page from AJAX action that updates a div
- Text field not being submitted via form_remote_tag; works via form_tag
- Dynamically uploading a list that's already in a form