Updating multiple divs w/ RJS/AJAX
Posted
by bgadoci
on Stack Overflow
See other posts from Stack Overflow
or by bgadoci
Published on 2010-05-21T02:36:57Z
Indexed on
2010/05/21
2:40 UTC
Read the original article
Hit count: 341
I am successfully using RJS to implement AJAX on a page.replace.html create.js.rjs. I am attempting to update two locations instead of one and after watching Ryan Bates Railscast I am very close (I think) but have a problem in the syntax of my /views/likes/create.js.rjs file. Here is the situation:
located at /views/likes/create.js.rjs is the following code:
page.replace_html "votes_#{ @site.id }", :partial => @like
page.replace_html "counter", 10 - (@question.likes.count :conditions => {:user_id => current_user.id})
page[@like].visual_effect :highlight
My problem lies in the second line. The div "counter" displays the following code in the /views/question/show.html.erb page:
<div id="counter">
You have <%= 10 - (@question.likes.count :conditions => {:user_id => current_user.id}) %> votes remaining for this question
</div>
From watching the screen cast I believe that my error has to do w/ the syntax of the second line. Specifically he mentions that you cannot use a local instance variable but not sure how to make the change. Thoughts?
© Stack Overflow or respective owner