render :update returns js wrapped in a HTML body

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

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

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

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

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.