This commit is contained in:
@@ -61,8 +61,8 @@
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label d-block" for="Input_IsPublished">발행 여부</label>
|
||||
<input type="hidden" name="Input.IsPublished" value="false" />
|
||||
<input class="form-check-input" id="Input_IsPublished" name="Input.IsPublished" type="checkbox" value="true" @(Model.IsPublished ? "checked" : null) />
|
||||
<input type="hidden" name="Input.IsPublished" value="@(Model.IsPublished ? "true" : "false")" data-blog-published-value />
|
||||
<input class="form-check-input" id="Input_IsPublished" type="checkbox" value="true" @(Model.IsPublished ? "checked" : null) data-blog-published-toggle />
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label" for="Input_ThumbnailUrl">썸네일 URL</label>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user