You may have a nested form for category within a root form as follows. And, you may use 'form_remote_tag' but if you click on the submit button for the nested form, it submits the root form.
%= start_form_tag :action => 'create' %>
div id="categories">
% form_remote_tag (:update => 'categories',
:url => { :action => 'add_category' }) do %>
%= text_field_tag 'new_price' %>
%= submit_tag 'Add' %>
% end %>
/div>
I have a solution even though it does not look pretty. You can just insert another form_remote_tag above the nested form:
%= start_form_tag :action => 'create' %>
%# faked form to avoid to submit the main form when addding review %>
% form_remote_tag(:url=>{:action =>'add_item'})do %>
% end %>
div id="categories">
% form_remote_tag (:update => 'categories',
:url => { :action => 'add_category' }) do %>
%= text_field_tag 'new_price' %>
%= submit_tag 'Add' %>
% end %>
/div>
% end_form_tag %>
No comments:
Post a Comment