dbmsv4 init...5
This commit is contained in:
parent
0c780611c9
commit
ae7e04ff89
@ -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();";
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
<?= session('message') ? session('message') : ""; ?>
|
||||
<div class="rounded border border-gray p-2 mt-3">
|
||||
<div style="font-size:15px">미지급 1회성정보</div>
|
||||
<table class="table table-bordered table-hover table-striped">
|
||||
|
||||
@ -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);
|
||||
});
|
||||
// ✅ 모달 열릴 때: "해당 모달만" 초기화하되 중복 호출 방지(네임스페이스)
|
||||
$(document)
|
||||
.off("shown.bs.modal.initForm", ".modal")
|
||||
.on("shown.bs.modal.initForm", ".modal", function () {
|
||||
window.initFormModal(this);
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user