Page replace with RJS
Posted
by Jiang
on Stack Overflow
See other posts from Stack Overflow
or by Jiang
Published on 2010-05-04T01:59:21Z
Indexed on
2010/05/04
2:08 UTC
Read the original article
Hit count: 425
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.
© Stack Overflow or respective owner