I wrote some code for adding a category to a list of categories on a
page, complete with some rjs effects. The code saves the category
alright but does not execute any js. I have to refresh to see any
changes. Here is what I have been using:
VIEW: list.html.erb
-
<%= render :partial => 'category', :collection => @categories %>
<% form_remote_tag :url => {:action => ‘new’},
:html => {:id => ‘category_form’} do %>
Name: <%= text_field ‘category’, ‘name’ %>
<%= submit_tag “Add” %>
<% end %>
CONTROLLER: category_controller.rb
def new
@category = Category.new(params[:category])
respond_to do |format|
if @category.save
format.js
render :partial => ‘category’, :object => @category
end
def list
@categories = Category.find(:all)
end
RJS: new.js.erb
page.insert_html :bottom, :category_list, :partial => ‘category’,
:object => @category
page.visual_effect :highlight, “category_#{category.id}”
page[:category_form].reset
Has anyone else run into this issue or have any ideas about where I am
going wrong?