wepic
January 8, 2008, 5:00pm
1
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)
use the page/hi.js.rjs
use the render :text => “alert(‘Im JS’);”, :content_type =>
“text/javascript”
respond_to do |format|
format.js
end
headers[“Content-Type”] = "text/javascript; charset=utf-8
Thank you all in advance!
//Nicklas Ramhöj
wepic
January 8, 2008, 5:52pm
2
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
wepic
January 8, 2008, 6:00pm
3
On 8 Jan 2008, at 16:00, Nicklas Ramhöj wrote:
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
wepic
January 8, 2008, 6:07pm
4
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 my
code 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
wepic
January 9, 2008, 9:16am
5
Hi.
I found it!
Argh, why didn’t I check this earlyer:
The bad guy:
Code :
#application .rb
after_filter :tidy
def tidy
RailsTidy.filter(response)
end
Thanks all for reading my post. Hope this helps any one else in the
furure.