Updated specific locations to be searchable, take a look at Las Vegas as an example.

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

4
Need some help integrating javascript into a voting button.
Post Body

So first things first, I have no idea how to use javascript. All I really know about it is that it allows me to change things without refreshing the page. I have no idea how to get my models/variables into javascript or where it falls in the timeline of asset service.

What I want is for the div containing the value @video.plusminus to update with the new value of @video.plusminus after the vote has been recorded.

show.html.erb:

<div>
<%= link_to "/videos/#{@video.id}/upvote", method: 'post', remote: true do %>
<i class="glyphicon glyphicon-chevron-up"></i>
<% end %>  
<div id="score"><%=@score%></div>

videos_controller.rb

def upvote
@video = Video.find(params[:id])
if current_user.voted_against?(@video)
  current_user.vote_exclusively_for(@video)
elsif current_user.voted_on?(@video)
  current_user.unvote_for(@video)
else
  current_user.vote_for(@video)
end
respond_to do |format|
  format.js
end
end

upvote.js.erb:

$("score").update.("<%= escape_javascript(render(@video.plusminus)) %>");

When I click the link, nothing happens, and I don't know why. If someone could explain the right way to do this to me, I'd be much obliged. I've never had to use javascript before and it's frustrating as hell.

Author
Account Strength
100%
Account Age
13 years
Verified Email
Yes
Verified Flair
No
Total Karma
10,478
Link Karma
8,040
Comment Karma
2,438
Profile updated: 4 days ago
Posts updated: 6 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
10 years ago