diff --git a/WebContent/WEB-INF/view/quality/processInspectionFormPopUp.jsp b/WebContent/WEB-INF/view/quality/processInspectionFormPopUp.jsp index ef0866e..129c0d1 100644 --- a/WebContent/WEB-INF/view/quality/processInspectionFormPopUp.jsp +++ b/WebContent/WEB-INF/view/quality/processInspectionFormPopUp.jsp @@ -181,6 +181,8 @@ function fn_select2Editor(cell, onRendered, success, cancel, editorParams) { var select = document.createElement("select"); select.style.width = "100%"; + select.style.opacity = "0"; + select.style.position = "absolute"; // 옵션 생성 if(values && values.length > 0) { @@ -203,21 +205,32 @@ function fn_select2Editor(cell, onRendered, success, cancel, editorParams) { width: "100%" }); $(select).select2("open"); - - $(select).on("select2:select select2:clear", function(e) { - var selectedVal = $(select).val() || ""; - - // 콜백 호출 (프로젝트 변경 시 연동 처리 등) - if(typeof editorParams.onSelect === "function") { - editorParams.onSelect(cell, selectedVal); - } - - success(selectedVal); - }); - - $(select).on("select2:close", function() { - setTimeout(function() { success($(select).val() || ""); }, 100); - }); + }); + + var isCleared = false; + + $(select).on("select2:select", function(e) { + var selectedVal = $(select).val() || ""; + if(typeof editorParams.onSelect === "function") { + editorParams.onSelect(cell, selectedVal); + } + success(selectedVal); + }); + + $(select).on("select2:clear", function(e) { + isCleared = true; + if(typeof editorParams.onSelect === "function") { + editorParams.onSelect(cell, ""); + } + setTimeout(function() { + $(select).select2("close"); + success(""); + }, 0); + }); + + $(select).on("select2:close", function() { + if(isCleared) return; + success($(select).val() || ""); }); return container; diff --git a/WebContent/WEB-INF/view/quality/semiProductInspectionFormPopUp.jsp b/WebContent/WEB-INF/view/quality/semiProductInspectionFormPopUp.jsp index e881b7d..1ac39de 100644 --- a/WebContent/WEB-INF/view/quality/semiProductInspectionFormPopUp.jsp +++ b/WebContent/WEB-INF/view/quality/semiProductInspectionFormPopUp.jsp @@ -386,6 +386,8 @@ function createSelect2Editor(options, allowClear) { var container = document.createElement("span"); var select = document.createElement("select"); select.style.width = "100%"; + select.style.opacity = "0"; + select.style.position = "absolute"; var emptyOption = document.createElement("option"); emptyOption.value = ""; @@ -410,14 +412,28 @@ function createSelect2Editor(options, allowClear) { allowClear: allowClear !== false, dropdownParent: $('body') }); - - $(select).on('select2:select select2:clear', function(e) { - success($(select).val() || ''); - }); - $(select).select2('open'); }); + var isCleared = false; + + $(select).on('select2:select', function(e) { + success($(select).val() || ''); + }); + + $(select).on('select2:clear', function(e) { + isCleared = true; + setTimeout(function() { + $(select).select2('close'); + success(''); + }, 0); + }); + + $(select).on('select2:close', function() { + if(isCleared) return; + success($(select).val() || ''); + }); + return container; }; }