From ae7e04ff89ece2df557e8555b5cc74d86f84b8b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Thu, 5 Feb 2026 17:52:39 +0900 Subject: [PATCH] dbmsv4 init...5 --- app/Traits/UtilTrait.php | 2 +- app/Views/cells/payment/detail.php | 1 - public/js/admin/form.js | 84 ++++++++++++++++++------------ 3 files changed, 51 insertions(+), 36 deletions(-) diff --git a/app/Traits/UtilTrait.php b/app/Traits/UtilTrait.php index 4312df0..79efd7d 100644 --- a/app/Traits/UtilTrait.php +++ b/app/Traits/UtilTrait.php @@ -91,7 +91,7 @@ trait UtilTrait final public function alertTrait(string $msg, $url = null): string { $safeMsg = json_encode($msg, JSON_UNESCAPED_UNICODE | JSON_HEX_TAG); - $js = "console.log({$safeMsg}); alert({$safeMsg});"; + $js = "alert({$safeMsg});"; switch ($url) { case 'close': $js .= "window.close();"; diff --git a/app/Views/cells/payment/detail.php b/app/Views/cells/payment/detail.php index f9b6e09..0d70a8a 100644 --- a/app/Views/cells/payment/detail.php +++ b/app/Views/cells/payment/detail.php @@ -1,4 +1,3 @@ -
미지급 1회성정보
diff --git a/public/js/admin/form.js b/public/js/admin/form.js index d8fd753..2a6296d 100644 --- a/public/js/admin/form.js +++ b/public/js/admin/form.js @@ -1,55 +1,71 @@ // /public/js/admin/form.js window.initFormModal = function (context) { - const $context = context ? $(context) : $(document); + const root = context || document; + const $root = $(root); - // ✅ 캘린더 - $context.find(".calender").datepicker({ - changeYear: true, - changeMonth: true, - yearRange: "-10:+0", - dateFormat: "yy-mm-dd" + // ✅ 캘린더: 이미 datepicker 붙은 건 제외 + $root.find(".calender").each(function () { + const $el = $(this); + if ($el.hasClass("hasDatepicker")) return; + $el.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: 전체 remove() 금지, "컨텍스트 내부 textarea만" 처리 + if (typeof tinymce !== "undefined") { + $root.find("textarea.tinymce").each(function () { + const id = this.id || ("tinymce_" + Math.random().toString(36).slice(2)); + this.id = id; + + // 이미 인스턴스 있으면 스킵 + if (tinymce.get(id)) return; + tinymce.init({ - selector: "textarea.tinymce", + selector: `#${CSS.escape(id)}`, 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); + // ✅ 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 () { window.initFormModal(document); }); -// ✅ Modal 로드 시점에 재초기화 -$(document).on("shown.bs.modal", ".modal", function (e) { - window.initFormModal(this); -}); \ No newline at end of file +// ✅ 모달 열릴 때: "해당 모달만" 초기화하되 중복 호출 방지(네임스페이스) +$(document) + .off("shown.bs.modal.initForm", ".modal") + .on("shown.bs.modal.initForm", ".modal", function () { + window.initFormModal(this); + });