55 lines
1.7 KiB
JavaScript
55 lines
1.7 KiB
JavaScript
// /public/js/admin/form.js
|
|
window.initFormModal = function (context) {
|
|
const $context = context ? $(context) : $(document);
|
|
|
|
// ✅ 캘린더
|
|
$context.find(".calender").datepicker({
|
|
changeYear: true,
|
|
changeMonth: true,
|
|
yearRange: "-10:+0",
|
|
dateFormat: "yy-mm-dd"
|
|
});
|
|
|
|
// ✅ TinyMCE
|
|
if ($context.find(".tinymce").length) {
|
|
if (typeof tinymce !== "undefined") {
|
|
tinymce.remove(); // 기존 인스턴스 제거
|
|
tinymce.init({
|
|
selector: "textarea.tinymce",
|
|
license_key: "gpl",
|
|
height: 250,
|
|
plugins: "advlist autolink lists link image charmap preview anchor",
|
|
toolbar: "undo redo | bold italic underline | align | link image | code fullscreen preview",
|
|
menubar: "file edit view insert format tools table help"
|
|
});
|
|
}
|
|
}
|
|
|
|
// ✅ Select2 (입력 허용)
|
|
if ($context.find(".select-field").length) {
|
|
$context.find(".select-field").select2({
|
|
theme: "bootstrap-5",
|
|
tags: true,
|
|
allowClear: true,
|
|
width: '100%',
|
|
dropdownAutoWidth: true,
|
|
language: {
|
|
noResults: function () {
|
|
return "직접 입력 후 Enter"; // 사용자 안내
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
console.log("✅ Form initialized inside modal:", context);
|
|
};
|
|
|
|
// ✅ DOM 전체 로드 후 (페이지 최초 로드시 실행)
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|
window.initFormModal(document);
|
|
});
|
|
|
|
// ✅ Modal 로드 시점에 재초기화
|
|
$(document).on("shown.bs.modal", ".modal", function (e) {
|
|
window.initFormModal(this);
|
|
}); |