로딩
요청 처리 중입니다...

[js] GenealUtil.confirm 처리시 holding하는 방법. 커스텀 컨펌 동기처리 방법 > Promise async await

 [js] GenealUtil.confirm 처리시 holding하는 방법. 커스텀 컨펌 동기처리 방법 > Promise async await

브라우저에서 지원하는 alert이나 confirm처럼 이후 코드를 실행하지 않고 기다리는것이 아니라 커스텀 confirm 실행시 비동기로 돌아가기때문에 GeneralUtil.confirm 밖에있는 코드들이 바로 실행된다. GeneralUtil.confirm("확인", "변경하시겠습니까?"

, function (){ fnSetDisable(value); fnResetInput(); }, function(){ $(this).val(condiVal); fnSetDisable(condiVal); }); fnSetDisable(value); // <- 이코드가 실행됨. condiVal = value; 커스텀 컨펌을 사용했을때 holding 할 수 있는 방법이 필요해 방법을 찾아보니 async await 를 사용하면 쉽게 처리할 수 있다. 아래 코드에서 async await를 주면 const result = await 가 실행된 이후, new Promise((resolve, reject) => ...