Hi, I''m trying to execute a .rjs, but instead of executing the javascript code, the javascript code is shown on the html. Does any one know why? thanks you very much Sayoyo ---------------------------------------------------------------------- example code: on main.rhtml, I have: <%= link_to_remote(''add'', :url=>{:action=>''openAdd''}, :update=>''addZone'')-%> <div id="addZone"></div> on MainController.rb I have def openAdd end on openAdd.rjs, I have page.replace_html("addZone", :partial=>"openAdd") on _openAdd.rhtml, I have "add opened" after click on "add" on the main.rhtml i got: try { Element.update("addControlZone", "add opened\n"); } catch (e) { alert(''RJS error:\n\n'' + e.toString()); alert(''Element.update(\"addControlZone\", \"toto\n\");''); throw e } -- 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 -~----------~----~----~----~------~----~------~--~---
> Hi, > > I''m trying to execute a .rjs, but instead of executing the javascript > code, the javascript code is shown on the html. Does any one know why?Do you render with :layout => false ? Like: render :template => ''logi/ajax_vote'', :layout => false Wybo> thanks you very much > > Sayoyo--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
No, you need to do: class MainController def openAdd render :partial => ''openAdd'' end end and rename openAdd.rjs to _openAdd.rjs. Jason On 1/24/07, Wybo Wiersma <wybo-T49n2wj3Ml5g9hUCZPvPmw@public.gmane.org> wrote:> > > > Hi, > > > > I''m trying to execute a .rjs, but instead of executing the javascript > > code, the javascript code is shown on the html. Does any one know why? > > Do you render with :layout => false ? > > Like: > render :template => ''logi/ajax_vote'', > :layout => false > > Wybo > > > thanks you very much > > > > Sayoyo > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
mcintyre.tim-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jan-24 18:39 UTC
Re: rjs not executing?
> on main.rhtml, I have: > <%= link_to_remote(''add'', :url=>{:action=>''openAdd''}, > :update=>''addZone'')-%> > <div id="addZone"></div> >Don''t use the :update option with rjs calls. That constructs an Ajax.Updater prototype object instead of the Ajax.Request object you need for rjs calls. On the other hand, if you only need to update one html element, I''d leave the :update option and just return a regular partial template, pretty sure it''s considerably faster. Good Luck, Tim --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks you very much for the information, but what exactly the difference between Ajax.request and Ajax.update??? Sayoyo unknown wrote:>> on main.rhtml, I have: >> <%= link_to_remote(''add'', :url=>{:action=>''openAdd''}, >> :update=>''addZone'')-%> >> <div id="addZone"></div> >> > > Don''t use the :update option with rjs calls. That constructs an > Ajax.Updater prototype object instead of the Ajax.Request object you > need for rjs calls. > > On the other hand, if you only need to update one html element, I''d > leave the :update option and just return a regular partial template, > pretty sure it''s considerably faster. > > Good Luck, > Tim-- 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 -~----------~----~----~----~------~----~------~--~---
The Updater is given a DOM id, which will then be rewritten with the response of the request. It''s what you use if you want to use AJAX but not RJS. The Requester just sends a request. I believe that they can both be told to execute the response text as javascript as well. Jason On 1/29/07, sayoyo <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Thanks you very much for the information, but what exactly the > difference between Ajax.request and Ajax.update??? > > > Sayoyo > > unknown wrote: > >> on main.rhtml, I have: > >> <%= link_to_remote(''add'', :url=>{:action=>''openAdd''}, > >> :update=>''addZone'')-%> > >> <div id="addZone"></div> > >> > > > > Don''t use the :update option with rjs calls. That constructs an > > Ajax.Updater prototype object instead of the Ajax.Request object you > > need for rjs calls. > > > > On the other hand, if you only need to update one html element, I''d > > leave the :update option and just return a regular partial template, > > pretty sure it''s considerably faster. > > > > Good Luck, > > Tim > > > -- > 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 -~----------~----~----~----~------~----~------~--~---