Hi,
I am having the following scenario to . In a page I have a list of
stories, I would like to add the voting fuctionality (digg style) for
each stories. I need the voting score to be displayed simultaniously
(using AJAX). I am using the following listed code snippet for this
but, I have a minor problem, since I am updating the <span
id="vote_score" ..> using the vote.rjs. It always updates the score
of
first story only. Does anyone has any solution for this. Thanks in
advance
_story.html.erb
--------------------------------
<% div_for story do %>
<h2><span id="vote_score"> <%= story.votes.size
%></span>
<span id="vote_link" >
<%= link_to_remote ''Vote Up'', {:url => {:action =>
''vote'', :id =>
post.id}},
{:href => url_for(:action => ''vote'', :id =>
story.id)}%>
<%= link_to_unless_current h(post.title), story %> </h2>
<%= simple_format h(story.body) %>
</span>
<% end %>
--------------------------------
vote.rjs
------------------------------------------------------------------------------
page.replace_html ''vote_score'',
"#{@post.votes.size}"
page[:vote_score].visual_effect :highlight
7stud --
2009-May-10 20:34 UTC
Re: nested ajax functionality in a span element inside div_f
RubyRed wrote:> Hi, > I am having the following scenario to . In a page I have a list of > stories, I would like to add the voting fuctionality (digg style) for > each stories. I need the voting score to be displayed simultaniously > (using AJAX). I am using the following listed code snippet for this > but, I have a minor problem, since I am updating the <span > id="vote_score" ..> using the vote.rjs. It always updates the score of > first story only. Does anyone has any solution for this. Thanks in > advance > > > > _story.html.erb > -------------------------------- > > <% div_for story do %> > <h2><span id="vote_score"> <%= story.votes.size %></span> > <span id="vote_link" > > <%= link_to_remote ''Vote Up'', {:url => {:action => ''vote'', :id => > post.id}}, > {:href => url_for(:action => ''vote'', :id => story.id)}%> > <%= link_to_unless_current h(post.title), story %> </h2> > <%= simple_format h(story.body) %> > </span> > > <% end %> > -------------------------------- > > > vote.rjs > ------------------------------------------------------------------------------ > page.replace_html ''vote_score'', "#{@post.votes.size}" > page[:vote_score].visual_effect :highlightHow about: page.replace_html ''vote_score'', "#{@post.votes.size}" page.replace_html ''another id'', "something else" which might lend itself to some sort of loop. -- Posted via http://www.ruby-forum.com/.