Hi all,
I'm using rails version 1.2.3, and I have a really weird problem: I'm trying to run a simple example for experimenting with rjs, that adds some xhtml to my page, actually it's the example on http://www.codyfauser.com/articles/2005/11/20/rails-rjs-templates.
The weird thing is that if I use an rjs my browser doesn't update, but if I us the "render :update do |page|" way it does.
I'm using FireBug on Firefox, and actually both ways respond the same javascript, but one is executed yet not the other.
What may I be doing wrong?
I leave you part of the code I'm using:
#test.rhtml
<html> <head> <title>Test</title> <%= javascript_include_tag :defaults %> </head> <body>
<h1 id='header'>RJS Template Test</h1> <ul id='list'> <li>Dog</li> <li>Cat</li> <li>Mouse</li> </ul> <%= link_to_remote("Add a fox", :url =>{ :action => :add }) %> </body> </html>
#test_controller.rb
class TestController < ApplicationController
def test end
def add # render :update do |page| # page.insert_html :bottom, 'list', content_tag("li", "Fox") # page.visual_effect :highlight, 'list', :duration => 3 # page.replace_html 'header', 'RJS Template Test Complete!' # end end
end
#add.rjs
page.insert_html :bottom, 'list', content_tag("li", "Fox") page.visual_effect :highlight, 'list', :duration => 3 page.replace_html 'header', 'RJS Template Test Complete!'
#response in both ways try { new Insertion.Bottom("list", "<li>Fox</li>"); new Effect.Highlight("list",{duration:3}); Element.update("header", "RJS Template Test Complete!"); } catch (e) { alert('RJS error:\n\n' + e.toString()); alert('new Insertion.Bottom(\"list\", \"<li>Fox </li>\");\nnew Effect.Highlight(\"list\",{duration:3}); \nElement.update(\"header\", \"RJS Template Test Complete!\");'); throw e }
Notice that the add action is commented, when I uncomment it, it works fine.
Any ideas on what's the problem?
Thanks a lot in advance
R@Y