`); const $thumbsDownButton = $('') .attr('data-id', comment.hash) .addClass(`thumbsdown px-3 py-2 text-sm ${comment.has_downvoted ? 'text-blue-700' : 'text-gray-400'}hover:text-blue-700`) .attr('onclick', 'thumbsDown(this);') .html(` thumb-down-outline `); $actionsButtonDiv.append($thumbsUpButton).append($thumbsDownButton); $actionsDiv.append($timeago).append($actionsButtonDiv); $commentDiv.append($actionsDiv); return $commentDiv; }; const thumbsUp = function (e){const commentId = $(e).data('id'); console.log(commentId) Livewire.emit('likeComment', commentId); }const thumbsDown = function (e){const commentId = $(e).data('id'); console.log(commentId) Livewire.emit('dislikeComment', commentId); }$(document).ready(function (){Livewire.on('new-comment-added', function (eventData){const $commentsList = $('#comments-list'); console.log($commentsList) $commentsList.find('.alert').remove(); const newComment = eventData.newComment; const $newCommentDiv = createCommentElement(newComment); console.log($commentsList) if ($commentsList.length){$commentsList.prepend($newCommentDiv); $newCommentDiv.fadeIn('slow'); }initTimeAgo(); }); Livewire.on('comments-updated', function (event){var $commentsList = $('#comments-list'); $.each(event.newComments, function (index, comment){const $commentDiv = createCommentElement(comment); $commentsList.append($commentDiv); $commentDiv.fadeIn('slow'); }); }); Livewire.on('voteStatusUpdated', (data) => { const commentId = data.commentId; console.log('commentId', commentId); const buttons = $(`button[data-id="${commentId}"]`); const thumbsUpButton = buttons.filter('.thumbsup'); const thumbsDownButton = buttons.filter('.thumbsdown'); console.log('thumbsUpButton', thumbsUpButton); console.log('thumbsDownButton', thumbsDownButton); if (data.status ==='up'){thumbsUpButton.removeClass(thumbsNormalClass).addClass(thumbsActiveClass); thumbsDownButton.removeClass(thumbsActiveClass).addClass(thumbsNormalClass); }else if (data.status ==='down'){thumbsDownButton.removeClass(thumbsNormalClass).addClass('text-blue-700'); thumbsUpButton.removeClass(thumbsActiveClass).addClass(thumbsNormalClass); }else if (data.status ==='cancelled'){thumbsUpButton.removeClass(thumbsActiveClass).addClass(thumbsNormalClass); thumbsDownButton.removeClass(thumbsActiveClass).addClass(thumbsNormalClass); }}); Livewire.on('commentDeleted', (commentId) => { $(`#comment-${commentId}`).fadeOut(); }); });