generated rjs replaces web page

I am running Rails 3.0.7 with Ruby 1.9.2 and using jquery. I ran

$ rails generate jquery:install

to get the right javascript files for AJAX.

HTML: <%= javascript_include_tag :all %> ... <div id="time_div">   I don't have the time, but   <%= link_to( "click here", :action=> 'say_when', :remote => true, :format => :js ) %>   and I will look it up. </div>

say_when.js.rjs: page.replace :time_div, "<p>The time is <b> #{DateTime.now.to_s} </b></

"

When I click on the link, instead of replacing the div html, the entire page is replaced with the generated javascript:

try { Element.replace("time_div", "<p>The time is <b> 2012-04-11T16:43:23-04:00 </b></p>"); } catch (e) { alert('RJS error:\n\n' + e.toString()); alert('Element.replace(\"time_div\", \"<p>The time is <b> 2012-04-11T16:43:23-04:00 </b></p>\");'); throw e }

page.replace_html does the same thing.

What am I doing wrong?

Solved my own problem. The link_to should be:

<%= link_to( "click here", {:action=> 'say_when', :format => :js}, :remote => true, :method => :post ) %>

I also had to replace say_when.js.rjs with

say_when.js.erb: $('#time_div').html('<p>The time is <b> <%= DateTime.now.to_s %> </b></