RP_Rave1_theme/template-parts/heart.js

27 lines
894 B
JavaScript
Raw Permalink Normal View History

2024-11-06 10:10:48 +00:00
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);
}
}
});
});
});