Fix blog publish checkbox binding
TaxBaik CI/CD / build-and-deploy (push) Successful in 56s

This commit is contained in:
2026-07-09 17:44:21 +09:00
parent bbb5d8dc55
commit 26ea7e17d0
2 changed files with 20 additions and 2 deletions
@@ -7,6 +7,9 @@
function setupEditor(root) {
const editor = root.querySelector('[data-blog-editor]');
const hiddenInput = root.querySelector('[data-blog-editor-value]');
const publishedToggle = root.querySelector('[data-blog-published-toggle]');
const publishedValue = root.querySelector('[data-blog-published-value]');
const form = root.querySelector('form');
const preview = root.querySelector('[data-blog-preview]');
const buttons = root.querySelectorAll('[data-blog-command]');
@@ -32,6 +35,21 @@
});
});
const syncPublishedState = () => {
if (publishedValue && publishedToggle) {
publishedValue.value = publishedToggle.checked ? 'true' : 'false';
}
};
if (publishedToggle) {
publishedToggle.addEventListener('change', syncPublishedState);
syncPublishedState();
}
if (form) {
form.addEventListener('submit', syncPublishedState);
}
syncEditor(editor, hiddenInput);
renderPreview();
}