# Can't get rjs templates running!

**URL:** <https://www.ruby-forum.com/t/cant-get-rjs-templates-running/112421>\
**Category:** Rails\
**Created:** [August 18, 2007, 5:36pm UTC](https://www.ruby-forum.com/t/cant-get-rjs-templates-running/112421 "2007-08-18T17:36:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![RSY](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ccd318/32.png) [@RSY](https://www.ruby-forum.com/u/RSY)\
**Post date:** [August 18, 2007, 5:36pm UTC](https://www.ruby-forum.com/t/cant-get-rjs-templates-running/112421/1 "2007-08-18T17:36:07Z")

</div>

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](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

 Test \<%= javascript\_include\_tag :defaults %\>

```
<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 }) %>

```

#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”, “

- Fox
”);  
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", "- 

\");\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
