Chapter 14
This commit is contained in:
16
public/js/question_show.js
Normal file
16
public/js/question_show.js
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Simple (ugly) code to handle the comment vote up/down
|
||||
*/
|
||||
var $container = $('.js-vote-arrows');
|
||||
$container.find('a').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
var $link = $(e.currentTarget);
|
||||
|
||||
$.ajax({
|
||||
url: '/comments/10/vote/'+$link.data('direction'),
|
||||
method: 'POST'
|
||||
}).then(function(response) {
|
||||
$container.find('.js-vote-total').text(response.votes);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user