0

Currently I am displaying the votes count statically on my page but I would like to find a way to make count update dynamically so that when I click the vote button it doesn't have to refresh the page to change the count.

This is the code in my view for the vote button

_post.html.erb

  <%= form_for(@vote, :remote => true) do |f| %>
     <%= f.hidden_field "post_id", :value => post.id %>
     <%= f.hidden_field "user_id", :value => current_user.id %>
     <%= image_submit_tag "arrow.png" %> 
  <% end %> 

This is the code in my view for how I'm rendering the count

_post.html.erb

I am using jquery and I tried to look for a way to update the count but haven't found much information. Thanks for the help I appreciate it.

Michael Peralta
  • 293
  • 5
  • 18

1 Answers1

0

check this railscasts http://railscasts.com/episodes/205-unobtrusive-javascript

you will get brief idea how to update data through ajax.

Pritesh Jain
  • 9,106
  • 4
  • 37
  • 51