RateMyCourse/frontpage/rateables/js/voting.js

34 lines
864 B
JavaScript
Raw Normal View History

$(function() {
var csrftoken = $("#csrf-token input").val();
2018-10-09 19:57:39 +00:00
$(".vote-up").click(function() {
2018-10-09 19:57:39 +00:00
var reviewId = $(this).attr("data-review-id");
var data = {
'csrfmiddlewaretoken': csrftoken,
'helpful': true
};
// Vote up
$.post(
'/api/postings/reviews/' + reviewId + '/helpful_vote/',
data,
function(result) { console.log(result); }
);
// Hide vote buttons
$("#review-votes-" + reviewId + " .review-vote-buttons").hide();
});
$(".vote-down").click(function() {
var reviewId = $(this).attr("data-review-id");
var data = {
'csrfmiddlewaretoken': csrftoken,
'helpful': false
};
// Vote down
$.post(
'/api/postings/reviews/' + reviewId + '/helpful_vote/',
data,
function(result) { console.log(result); }
);
// Hide vote buttons
$("#review-votes-" + reviewId + " .review-vote-buttons").hide();
});
});