Hi. From what I''m learned the below is suppose to return "alert(''Im JS'');" to the javascriptGenerator that''s suppose to make the page scream ''Im JS''...(?) render :update do |page| page.call :alert, "Im JS" end In Rails 1.2.3 it works perfectly. BUT in Rails 2.0.2 it returns the js neatly wrapped in a full HTML-body, and the browser shows me nada... (!) Please help me here, I''ve tried everything I can think of for hours now! Random things I''ve tryed (not in any order, and just glimpses) 1. use the page/hi.js.rjs 2. use the render :text => "alert(''Im JS'');", :content_type => "text/javascript" 3. respond_to do |format| format.js end 4. headers["Content-Type"] = "text/javascript; charset=utf-8 Thank you all in advance! //Nicklas Ramhöj Attachments: http://www.ruby-forum.com/attachment/1261/render_update.rb -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I forgot to describing my environment: Ruby version 1.8.6 (i686-darwin8.9.1) RubyGems version 1.0.1 Rails version 2.0.2 Active Record version 2.0.2 Action Pack version 2.0.2 Active Resource version 2.0.2 Action Mailer version 2.0.2 Active Support version 2.0.2 Environment development Database adapter mysql Mac OS X Leopard Firefox 2.0.0.11 Safari 3.0.4 -- 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-Jan-08 16:59 UTC
Re: render :update returns js wrapped in a HTML body
On 8 Jan 2008, at 16:00, Nicklas Ramhöj wrote:> > Hi. > > From what I''m learned the below is suppose to return "alert(''Im JS'');" > to the javascriptGenerator that''s suppose to make the page scream ''Im > JS''...(?) > > render :update do |page| > page.call :alert, "Im JS" > end > > In Rails 1.2.3 it works perfectly. > > BUT in Rails 2.0.2 it returns the js neatly wrapped in a full HTML- > body, > and the browser shows me nada... (!) >Is rails being dumb and adding a layout ? (in which case adding :layout => false should help) Fred> Please help me here, I''ve tried everything I can think of for hours > now! > > Random things I''ve tryed (not in any order, and just glimpses) > 1. use the page/hi.js.rjs > 2. use the render :text => "alert(''Im JS'');", :content_type => > "text/javascript" > 3. respond_to do |format| > format.js > end > 4. headers["Content-Type"] = "text/javascript; charset=utf-8 > > Thank you all in advance! > //Nicklas Ramhöj > > Attachments: > http://www.ruby-forum.com/attachment/1261/render_update.rb > > -- > 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> Is rails being dumb and adding a layout ? (in which case > adding :layout => false should help)My guess once too, but 1. it''s not my layout that''s being rendered around the JS, but just a <html><head><title></title></head><body>my code</body></html> and 2 I''ve tried: render :update, :layout => false, :content_type => "text/javascript" do |page| page.call :alert, "Im JS" end (sorry for not mentioned that above!) Thanks for your help, please let me know if you can think of anything else... //Nicklas -- 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 found it! Argh, why didn''t I check this earlyer: The bad guy: Code : 1. #application.rb 2. after_filter :tidy 3. def tidy 4. RailsTidy.filter(response) 5. end Thanks all for reading my post. Hope this helps any one else in the furure. -- 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 -~----------~----~----~----~------~----~------~--~---