I have a page that has a dropdown which i''m using observe_field on to make an ajax call back to my controller. The page initially displays fine. The method is invoked in my controller when i select a choice in the dropdown and I have an rjs file which is then invoked. The rjs file looks like this: page.replace_html ''embed_calendar'', :partial => ''shared/calendar'', :year => 2006, :month => 5, :table_class => "calendar_helper" So, I''m assuming that the _calendar.rhtml will be rendered in the embed_calendar div. My controller uses a template called main so i have a main.rhtml which has multiple partials in it for various sections of the page - all with their own divs. Then I have @content_for_layout in it as well. This is where my index.rhtml is initially rendered - it looks like this: <div id="main_content"> <%= start_form_tag(:action => "add") %> <div id="junk"> <h1>my calendar</h1> <%= select(:month, :id, [[''January'',1],[''February'',2],[''March'',3], [''April'',4],[''May'',5],[''June'',6], [''July'',7],[''August'',8],[''September'',9], [''October'',10],[''November'',11],[''December'',12]] , {:selected => @month}) %> <%= select(:year, :id, [[''2005'',2005],[''2006'',2006],[''2007'',2007], [''2008'',2008],[''2009'',2009],[''2010'',2010]], {:selected => @year}) %> <%= observe_field ''month_id'', :update => ''main_content'', :url => { :controller => ''calendar'', :action => ''modify_month_view''} %> <%= observe_field ''year_id'', :update => ''main_content'', :url => { :controller => ''calendar'', :action => ''modify_year_view''} %> </div> <div id="embed_calendar"> <%= render(:partial => "shared/calendar") %> </div> <%= end_form_tag %> </div> So when the rjs attempts to write the _calendar partial to the embed_calendar div - what it looks like it does is write it to the @content_for_layout section of my main.rhtml. I''ve used the DOM inspector and saw that this is what it did. So my first question is why does the rjs not really update the DOM in the div which i specified and second why does it display the page like its text like this: ry { Element.update("embed_calendar", " \n\t\t\t\t \n\t\n\t\t\n\t\t\tNovember\n\t\t \n\t\t\n\t\t\tSun\t\t\t Mon\t\t\t Tue\t\t\t Wed\t\t\t Thu\t\t\t Fri\t\t\t Sat\t\t \n\t Thanks, Jeff -- Posted via http://www.ruby-forum.com/.
Pete Wright
2006-Aug-02 00:48 UTC
[Rails] Ajax and observe_field not updating specified DIV
Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 186 bytes Desc: This is a digitally signed message part Url : http://wrath.rubyonrails.org/pipermail/rails/attachments/20060802/cea2c2f0/PGP-0001.bin