Hi All,
I have an ''admin'' controller in which I have a
''show_product'' action. In
the view of this action, I have a list of names of the categories w/
checkboxes to the left of each.
What I am trying to do is to allow the administrator to just check off
the categories in this show_product view and have it add the product to
the category.
That part I am not able to figure out is how to display the list of
categories & checkboxes and create observe_form''s or
observe_field''s to
send the product_id and category_id to the action that will do the logic
part.
Here is the code I''ve got:
# @categories & @product is available to the show_product action as
variables
# _categories.rhtml (partial gets called into the show_product.rhtml
<% if @categories %>
<% for category in @categories %>
<div style="clear:both">
<form id=''<%= category.id %>''>
<%= check_box :category_id, :value => category.id %>
<%= label :category, :name, category.name %>
<%= observe_form category.id,
:frequency => 1.0,
:update => ''category_notice'',
:url => {
:controller => ''admin'',
:action => ''update_product_category'' },
:with => "''category='' +
encodeURIComponent($(''@category.id'').value) +
''&product='' +
encodeURIComponent($(''@product'').value)" %>
</form>
</div>
<% end %>
<br /><br />
<% else %>
<p>No categories found.</p>
<% end %>
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---