Update chart as part of XHR request?

3 views
Skip to first unread message

MarkHoffman

unread,
Jan 28, 2010, 6:29:42 PM1/28/10
to ZiYa Plugin
How do I go about updating the chart as part of an AJAX request? Here
is my scenario:

1. The page is loaded and the chart is displayed. (Via a partial
called "chart")
2. The user clicks a checkbox which triggers a call to an action (via
observe_field) that recalculates the data for the chart. Now I want to
re-draw the chart.

Just calling the same code that renders the chart on the first load
doesn't work. (Didn't think it would, but I tried). I then tried
adding this code after it:

if request.xhr? then
render :update do |page|
page.replace_html( "chart", :partial => "chart")
end
end

But that doesn't do anything either. I'm sure it's something stupid
and silly that I'm missing, but I'm still getting used to Rails and
I'm not sure what I don't know. Thanks for any pointers or tips.

Reply all
Reply to author
Forward
0 new messages