찾다보니 알럿을 두개 띄우는 더 좋은 방법을 알게되었다!
swal("첫 번째 알럿")
.then((value) => {
swal("두 번째 알럿")
});
더 간단!ㅎㅎ
------------------- 이전에 썼던 방법 -----------------------
sweetAlert을 사용하여 2번의 확인 alert를 연달아 띄워야하는데
첫번째 alert만 뜨고 두번째 alert는 뜨지 않는 문제가 생겼다.
첫번째 alert에서 확인을 누르면 두번째 alert이 떠야하지만
확인을 누르는 순간 alert를 close해버리기 때문에 두번째 alert가 보여지지 않고 닫혀버리는 것이다.
그래서 해결방법은...!
첫번째 alert에서 확인을 눌렀을때 alert을 닫지 않도록 설정해야한다.
그래서 두번째 alert이 보이도록!
그렇게 설정하기 위해서는
closeOnConfirm:false;
-> 이 옵션을 추가하면된다!
function firstAlert(){
swal({
title: "First Alert",
text: "첫 번째 알럿입니다!",
icon: "warning",
buttons: true,
showCancelButton: true,
closeOnConfirm: false, ///확인버튼 클릭 시 알럿이 close되지 않게 설정
confirmButtonText : "확인",
cancelButtonText : "취소"
},
function(isConfirm){
secondAlert(); //확인을 누르면 두번째 sweeet alert을 띄움!
});
}
function secondAlert(){
if(true){
swal({
title: "Second Alert",
text: "두 번째 알럿입니다!",
icon: "warning",
buttons: true,
showCancelButton: true,
confirmButtonText : "확인",
cancelButtonText : "취소"
},
function(isConfirm){
});
}else{
swal.close();
}
}
'Web > JavaScript' 카테고리의 다른 글
모바일웹 sortable 적용안되는 문제 - touch-punch.js 추가해서 해결 (0) | 2020.12.23 |
---|---|
크롬 개발자 도구 (0) | 2020.12.23 |
e.stopPropagation(); (0) | 2020.10.22 |
timepicker를 대신할 수 있는 clockpicker 사용법 (0) | 2019.11.28 |
bootstrap daterange 날짜 제한 endDate 설정 (0) | 2019.10.07 |
댓글