Hi all,
I try to implement a vote feature in one of my rails projects. I use the following codes (in vote.rjs) to replace the page with a Partial template (_vote.rhtml). But when I click, the vote number can not be updated immediately. I have to refresh the page to see the change.
vote.rjs
page.replace("votes#{@foundphoto.id}", :partial="vote", :locals={:voteable=@foundphoto})
The partial template is as follows:
_vote.rhtml
"
<%= link_to_remote "+(#{voteable.votes_for})",
:update="vote",
:url = { :action="vote",
:id=voteable.id,
:vote="for"} %
/
<%= link_to_remote "-(#{voteable.votes_against})",
:update="vote",
:url = { :action="vote",
:id=voteable.id,
:vote="against"} %
any ideas? Thanks.