File: /mnt/data/ifa-wp/wp-content/themes/dreamsrent/assets/js/notification.js
jQuery(document).ready(function ($) {
// Load notifications when the bell icon is clicked
$('#notification-bell').on('click', function () {
$.ajax({
url: notificationData.ajax_url,
type: 'POST',
data: {
action: 'fetch_notifications'
},
success: function (response) {
if (response.success) {
$('#notification-dropdown').html(response.data.html);
$('#notification-count').text(response.data.unread_count > 0 ? response.data.unread_count : '');
}
}
});
});
// Clear all notifications when 'Clear All' is clicked
$(document).on('click', '.clear-noti', function () {
$.ajax({
url: notificationData.ajax_url,
type: 'POST',
data: {
action: 'clear_notifications',
user_id: notificationData.user_id // Ensure this is passed if needed
},
success: function (response) {
if (response.success) {
$('#notification-dropdown .noti-content .notification-list').html('<li class="notification-message"><p>No new notifications.</p></li>');
$('#notification-count').text(''); // Clear the notification count
}
}
});
});
});