TIST-39: added ajax to daily meals select #33

Merged
greendavid004 merged 3 commits from TIST-39 into develop 2025-07-05 20:52:28 +02:00
2 changed files with 10 additions and 1 deletions
Showing only changes of commit 4ccb8ac05e - Show all commits

View File

@ -12,7 +12,7 @@ the_header(
?>
<div id="recipe-id" hidden><?= $context['recipe']->get_id() ?></div>
<div id="in-usermenu" hidden></div>
<div id="in-usermenu" hidden><?= $context['recipe']->in_usermenu; ?></div>
<div class="container">
<div class="single-recipe">

View File

@ -15,7 +15,16 @@ document.addEventListener('click', (e) => {
const options = document.querySelectorAll('.dropdown-item');
const inUsermenu = document.getElementById('in-usermenu').textContent;
if (inUsermenu) {
options.forEach(option => {
if (option.getAttribute('data-value') === inUsermenu && option.getAttribute('data-value') !== 'remove') {
option.classList.add('dropdown-selected');
toggleBtn.textContent = option.textContent;
}
});
}
options.forEach(option => {
option.addEventListener('click', async (e) => {
const selectedValue = option.getAttribute('data-value');