472,119 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

render :update returns js wrapped in a HTML body

render :update returns js wrapped in a HTML body


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

1. render :update do |page|
2. page.call :alert, "Im JS"
3. 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 approach

1. :text => "alert('Im JS');", :content_type => "text/javascript"

1. respond_to do |format|
2. format.js
3. end

1. headers["Content-Type"] = "text/javascript; charset=utf-8

1. render :update, :layout => false, :content_type => "text/javascript" do
2. |page|
3. page.call :alert, "Im JS"
4. end

Thank you all in advance!
//Nicklas Ramhöj

Below is my environment:

2. Ruby version 1.8.6 (i686-darwin8.9.1)
3. RubyGems version 1.0.1
4. Rails version 2.0.2
5. Active Record version 2.0.2
6. Action Pack version 2.0.2
7. Active Resource version 2.0.2
8. Action Mailer version 2.0.2
9. Active Support version 2.0.2
10. Environment development
11. Database adapter mysql
13. Mac OS X Leopard
14. Firefox
15. Safari 3.0.4

This thread can also be found at: http://www.ruby-forum.com/topic/138029#614027 and http://railsforum.com/viewtopic.php?pid=50104#p50104
Jan 8 '08 #1
1 7519
303 Expert 100+
I don't know about Rails 2.0.2, but in Rails 1.2.3
Expand|Select|Wrap|Line Numbers
  1. render :update do |page|
  2.   page << "alert('Im JS')"
  3. end
writes the raw JavaScript to the page.
Jan 9 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by John Hughes | last post: by
1 post views Thread by Markw | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.