I am trying to make a render :update work, and couldn''t find anything on the forums or in books on what I am doing wrong: def index render :update do |page| page.replace_html ''asection'', :text => ''99'' (or :partial => ''somepartial'' etc.) end end this never works. Instead, the javascript is rendered on the page - perhaps because it failed? - instead of the result of the execution itself. Once, an alert was actually popped up (so it did execute in one case, but failed). In most cases, nothing happens other than the replacement of the element by the javascript code, which looks something like: try { Element.update("asection", "99\n"); } catch (e) { alert(''RJS error:\n\n'' + e.toString()); alert(''Element.update(\"asection\", \"99\\n\");''); throw e } replacing <div id=''asection''> replace me </div> the following always works, I don''t have a problem with basic partials: def index render :partial => ''somepartial'' end in both cases, the controller is called from a periodically_call_remote statement What am I doing wrong? Thanks in advance for any assistance. -- 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Jun-05 16:39 UTC
Re: render :update vs. render :partial -> need :update help
On 5 Jun 2008, at 17:36, DJ Cole wrote:> > try { Element.update("asection", "99\n"); } catch (e) { alert(''RJS > error:\n\n'' + e.toString()); alert(''Element.update(\"asection\", > \"99\\n\");''); throw e } > > replacing > <div id=''asection''> > replace me > </div> > > the following always works, I don''t have a problem with basic > partials: > > def index > render :partial => ''somepartial'' > end > > in both cases, the controller is called from a > periodically_call_remote > statement >Are you passing :update to periodically_call_remote? If so, don''t (that tells prototype that you''ll be giving it a chunk of data to insert rather than some js to execute. Fred> What am I doing wrong? Thanks in advance for any assistance. > -- > 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 -~----------~----~----~----~------~----~------~--~---
Thorsten Mueller
2008-Jun-05 16:40 UTC
Re: render :update vs. render :partial -> need :update help
Most likely you''re using th :update option of periodically_call_remote In this case it expects pure html as response and will treat your js as such Just kkep out the :update, your page.replace tells the browser what to replace anyway -- 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 -~----------~----~----~----~------~----~------~--~---