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></
p>"

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?

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to