This commit is contained in:
@@ -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();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user