dbmsv4 init...5

This commit is contained in:
최준흠 2026-02-05 17:52:39 +09:00
parent 0c780611c9
commit ae7e04ff89
3 changed files with 51 additions and 36 deletions

View File

@ -91,7 +91,7 @@ trait UtilTrait
final public function alertTrait(string $msg, $url = null): string final public function alertTrait(string $msg, $url = null): string
{ {
$safeMsg = json_encode($msg, JSON_UNESCAPED_UNICODE | JSON_HEX_TAG); $safeMsg = json_encode($msg, JSON_UNESCAPED_UNICODE | JSON_HEX_TAG);
$js = "console.log({$safeMsg}); alert({$safeMsg});"; $js = "alert({$safeMsg});";
switch ($url) { switch ($url) {
case 'close': case 'close':
$js .= "window.close();"; $js .= "window.close();";

View File

@ -1,4 +1,3 @@
<?= session('message') ? session('message') : ""; ?>
<div class="rounded border border-gray p-2 mt-3"> <div class="rounded border border-gray p-2 mt-3">
<div style="font-size:15px">미지급 1회성정보</div> <div style="font-size:15px">미지급 1회성정보</div>
<table class="table table-bordered table-hover table-striped"> <table class="table table-bordered table-hover table-striped">

View File

@ -1,55 +1,71 @@
// /public/js/admin/form.js // /public/js/admin/form.js
window.initFormModal = function (context) { window.initFormModal = function (context) {
const $context = context ? $(context) : $(document); const root = context || document;
const $root = $(root);
// ✅ 캘린더 // ✅ 캘린더: 이미 datepicker 붙은 건 제외
$context.find(".calender").datepicker({ $root.find(".calender").each(function () {
changeYear: true, const $el = $(this);
changeMonth: true, if ($el.hasClass("hasDatepicker")) return;
yearRange: "-10:+0", $el.datepicker({
dateFormat: "yy-mm-dd" changeYear: true,
changeMonth: true,
yearRange: "-10:+0",
dateFormat: "yy-mm-dd"
});
}); });
// ✅ TinyMCE // ✅ TinyMCE: 전체 remove() 금지, "컨텍스트 내부 textarea만" 처리
if ($context.find(".tinymce").length) { if (typeof tinymce !== "undefined") {
if (typeof tinymce !== "undefined") { $root.find("textarea.tinymce").each(function () {
tinymce.remove(); // 기존 인스턴스 제거 const id = this.id || ("tinymce_" + Math.random().toString(36).slice(2));
this.id = id;
// 이미 인스턴스 있으면 스킵
if (tinymce.get(id)) return;
tinymce.init({ tinymce.init({
selector: "textarea.tinymce", selector: `#${CSS.escape(id)}`,
license_key: "gpl", license_key: "gpl",
height: 250, height: 250,
plugins: "advlist autolink lists link image charmap preview anchor", plugins: "advlist autolink lists link image charmap preview anchor",
toolbar: "undo redo | bold italic underline | align | link image | code fullscreen preview", toolbar: "undo redo | bold italic underline | align | link image | code fullscreen preview",
menubar: "file edit view insert format tools table help" 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); // ✅ Select2: 이미 select2 붙은 건 제외
$root.find(".select-field").each(function () {
const $el = $(this);
if ($el.hasClass("select2-hidden-accessible")) return;
$el.select2({
theme: "bootstrap-5",
tags: true,
allowClear: true,
width: "100%",
dropdownAutoWidth: true,
language: {
noResults: function () {
return "직접 입력 후 Enter";
}
}
});
});
// 디버그 로그는 필요 없으면 제거/조건부로
// console.log("✅ Form initialized inside modal:", root);
}; };
// ✅ DOM 전체 로드 후 (페이지 최초 로드시 실행) // ✅ 페이지 최초 1회
document.addEventListener("DOMContentLoaded", function () { document.addEventListener("DOMContentLoaded", function () {
window.initFormModal(document); window.initFormModal(document);
}); });
// ✅ Modal 로드 시점에 재초기화 // ✅ 모달 열릴 때: "해당 모달만" 초기화하되 중복 호출 방지(네임스페이스)
$(document).on("shown.bs.modal", ".modal", function (e) { $(document)
window.initFormModal(this); .off("shown.bs.modal.initForm", ".modal")
}); .on("shown.bs.modal.initForm", ".modal", function () {
window.initFormModal(this);
});