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
@@ -61,8 +61,8 @@
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<label class="form-label d-block" for="Input_IsPublished">발행 여부</label> <label class="form-label d-block" for="Input_IsPublished">발행 여부</label>
<input type="hidden" name="Input.IsPublished" value="false" /> <input type="hidden" name="Input.IsPublished" value="@(Model.IsPublished ? "true" : "false")" data-blog-published-value />
<input class="form-check-input" id="Input_IsPublished" name="Input.IsPublished" type="checkbox" value="true" @(Model.IsPublished ? "checked" : null) /> <input class="form-check-input" id="Input_IsPublished" type="checkbox" value="true" @(Model.IsPublished ? "checked" : null) data-blog-published-toggle />
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<label class="form-label" for="Input_ThumbnailUrl">썸네일 URL</label> <label class="form-label" for="Input_ThumbnailUrl">썸네일 URL</label>
@@ -7,6 +7,9 @@
function setupEditor(root) { function setupEditor(root) {
const editor = root.querySelector('[data-blog-editor]'); const editor = root.querySelector('[data-blog-editor]');
const hiddenInput = root.querySelector('[data-blog-editor-value]'); 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 preview = root.querySelector('[data-blog-preview]');
const buttons = root.querySelectorAll('[data-blog-command]'); 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); syncEditor(editor, hiddenInput);
renderPreview(); renderPreview();
} }