Skip to content

Commit

Permalink
Fix #183 provided by @bobrik-matej
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-code committed Nov 6, 2019
2 parents 196c120 + 5bb6b8a commit 5b878ba
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
22 changes: 14 additions & 8 deletions bootcamp/static/js/qa.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,13 @@ $(function () {
type: 'post',
cache: false,
success: function (data) {
$('.vote', span).removeClass('voted');
if (vote === "U") {
$(span).addClass('voted');
}
if (vote === "U") {
$('#questionUpVote').addClass('voted');
$('#questionDownVote').removeClass('voted');
} else {
$('#questionDownVote').addClass('voted');
$('#questionUpVote').removeClass('voted');
}
$("#questionVotes").text(data.votes);
}
});
Expand All @@ -93,10 +96,13 @@ $(function () {
type: 'post',
cache: false,
success: function (data) {
$('.vote', span).removeClass('voted');
if (vote === "U") {
$(span).addClass('voted');
}
if (vote === "U") {
$('#answerUpVote').addClass('voted');
$('#answerDownVote').removeClass('voted');
} else {
$('#answerDownVote').addClass('voted');
$('#answerUpVote').removeClass('voted');
}
$("#answerVotes").text(data.votes);
}
});
Expand Down
4 changes: 2 additions & 2 deletions bootcamp/templates/qa/answer_sample.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<div class="row answer" answer-id="{{ answer.uuid_id }}">
{% csrf_token %}
<div class="col-md-1 options">
<i class="fa fa-chevron-up vote up-vote answer-vote {% if request.user in answer.get_upvoters %}voted{% endif %}" aria-hidden="true" title="{% trans 'Click to up vote; click again to toggle' %}"></i>
<i id="answerUpVote" class="fa fa-chevron-up vote up-vote answer-vote {% if request.user in answer.get_upvoters %}voted{% endif %}" aria-hidden="true" title="{% trans 'Click to up vote; click again to toggle' %}"></i>
<span id="answerVotes" class="votes">{{ answer.total_votes }}</span>
<i class="fa fa-chevron-down vote down-vote answer-vote {% if request.user in answer.get_downvoters %}voted{% endif %}" aria-hidden="true" title="{% trans 'Click to down vote; click again to toggle' %}"></i>
<i id="answerDownVote" class="fa fa-chevron-down vote down-vote answer-vote {% if request.user in answer.get_downvoters %}voted{% endif %}" aria-hidden="true" title="{% trans 'Click to down vote; click again to toggle' %}"></i>
{% if answer.is_answer and user == question.user %}
<i id="acceptAnswer" class="fa fa-check accept accepted" aria-hidden="true" title="{% trans 'Click to unaccept the answer' %}"></i>
{% elif answer.is_answer %}
Expand Down

0 comments on commit 5b878ba

Please sign in to comment.