RP_Rave1_theme/template-parts/heart.js
Virág Gábor 4664ef511d upload
2024-11-06 11:10:48 +01:00

26 lines
894 B
JavaScript

jQuery(document).ready(function($) {
$('.heart-icon').on('click', function() {
var post_id = $(this).attr('id').split('-')[2];
var $icon = $('#heart-icon-' + post_id);
var $text = $('#heart-text-' + post_id);
var $count = $('#heart-count-' + post_id);
$.ajax({
url: ajaxurl,
type: 'POST',
data: {
action: 'register_heart_click',
post_id: post_id
},
success: function(response) {
if (response.success) {
$icon.removeClass('fa-regular fa-heart').addClass('fa-solid fa-heart');
$text.text('Köszönjük a kattintást!');
$count.text(response.data.heart_count);
} else {
alert(response.data);
}
}
});
});
});