Hello everyone, I''m new to Ruby on Rails and I''m using the book Rails Solutions: Ruby on Rails Made Easy as my reference. I''m now in Chapter 8 where it touches the application of AJAX to Rails application. However, the code didn''t work and when I checked the browser. It returned an error message of "${element} has no properties". This is the code snippet that I followed: <p id="add_link"><%= link_to_function("Add a category", "Element.remove(''add_link'');Element.show(''add_category'')")%></p> <div id="add_category" style="display:none;"> <%= form_remote_tag(:url => {:action => ''new''},➥ :update => "category_list", :position => :bottom,➥ RAILS SOLUTIONS: RAILS MADE EASY 132 :html => {:id => ''category_form''})%> Name: <%= text_field "category", "name" %> <%= submit_tag ''Add'' %> <%= end_form_tag % By the way, I''m using Rails 2.0.2 Any advice? Thank in advance. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
I somehow messed up the code. Here''s the correct version. <ul id="category_list"> <%= render :partial => ''category'', :collection => @categories %> </ul> <p id="add_link"><%= link_to_function("Add a category", "Element.remove(''add_link''); Element.show(''add_category'')")%></p> <div id="add_cateogry" style="display:none;"> <% form_remote_tag( :url => {:action => ''new''}, :update => "category_list", :position => :bottom, :html => {:id => ''category_form''}) do -%> Name: <%= text_field "category", "name" %> <%= submit_tag ''Add'' %> <% end %> </div> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
My bad! I discovered the cause of the problem. It is due to the <div id="add_cateogry"... line I changed it to add_category and it''s now working. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---