refactor: Adjust the Add button to display only on the Location tab

main-dlh
Regiaaaaaa 2025-11-14 09:50:52 +07:00
parent 7fb32bf4cc
commit 7a104907df
1 changed files with 23 additions and 5 deletions

View File

@ -16,11 +16,11 @@
<h3 class="mb-2">Profil Rw</h3>
</div>
<div class="justify-self-end lg:self-center">
<label for="modal-tambah"
class="btn rounded-full bg-green-600 hover:bg-green-700 text-white border-0 shadow-sm transition duration-200">
<span class="icon icon-fill me-2">add</span>
Tambah
</label>
<label id="btn-tambah" for="modal-tambah"
class="btn rounded-full bg-green-600 hover:bg-green-700 text-white border-0 shadow-sm transition duration-200">
<span class="icon icon-fill me-2">add</span>
Tambah
</label>
</div>
</div>
@ -192,4 +192,22 @@
console.log('Detail clicked for ID:', id);
});
});
// Toggle "Tambah" button visibility based on active tab
const toggleTambahButton = () => {
const active = $('input[name="tab_profil_rw"]:checked').attr('aria-label');
if (active === "Lokasi TP3SR & Parkir Pengumpulan Sampah") {
$('#btn-tambah').show();
} else {
$('#btn-tambah').hide();
}
};
// initial check
toggleTambahButton();
// bind change event
$('input[name="tab_profil_rw"]').on('change', toggleTambahButton);
</script>