open modal on create plan click
This commit is contained in:
parent
3d88a1d816
commit
389e125cef
1 changed files with 16 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
const textsList = document.getElementById('texts-list');
|
const textsList = document.getElementById('texts-list');
|
||||||
|
const createPlanModal = document.getElementById('create-plan-modal');
|
||||||
|
|
||||||
async function loadTexts() {
|
async function loadTexts() {
|
||||||
const response = await fetch('/api/texts');
|
const response = await fetch('/api/texts');
|
||||||
|
|
@ -13,5 +14,20 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
.join('');
|
.join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openCreatePlanModal(textId) {
|
||||||
|
createPlanModal.dataset.textId = textId;
|
||||||
|
createPlanModal.hidden = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
textsList.addEventListener('click', (clickEvent) => {
|
||||||
|
const createPlanButton = clickEvent.target.closest(
|
||||||
|
'button.create-plan'
|
||||||
|
);
|
||||||
|
if (createPlanButton === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
openCreatePlanModal(createPlanButton.dataset.textId);
|
||||||
|
});
|
||||||
|
|
||||||
loadTexts();
|
loadTexts();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue