Ajax 요청 완료 시 sweet alert를 닫는 방법
사용 중Sweet-alert
내 각진 앱에서.
function GetDataFromServer(url) {
SweetAlert.swal(
{
title: "",
text: "Please wait.",
imageUrl: "../../app/app-img/loading_spinner.gif",
showConfirmButton: false
});
return $http.get(url)
.then(success)
.catch(exception);
function success(response) {
//SweetAlert.swal(
// {
// title: "",
// text: "data loaded",
// });
return response.data;
}
function exception(ex) {
return (ex);
}
}
요청 #1(이 게시물의 주요 목표)
제가 찾고 있는 것은 아약스 요청이 완료될 때, 즉 ()에 컨트롤이 입력되면 Sweet alert가 자동으로 숨겨집니다.
요청 #2 또한 요청 처리 중에 sweet alert에서 Close 팝업 버튼(Ok 버튼)을 사용하지 않습니다.
문서에 따르면,
showConfirmButton: false
숨겨야 하는데 그게 아닙니다.
어떠한 도움/제안도 대단히 감사합니다.
감사해요.
팝업이 완료되면 자동으로 팝업을 숨기려면 나중에 액세스할 수 있도록 초기 팝업을 변수로 설정해야 합니다.아마도:
function GetDataFromServer(url) {
SweetAlert.swal({
title: "",
text: "Please wait.",
imageUrl: "../../app/app-img/loading_spinner.gif",
showConfirmButton: false
});
return $http.get(url)
.then(success)
.catch(exception);
function success(response) {
swal.close()
return response.data;
}
function exception(ex) {
return (ex);
}
}
바로 아래에 있는 방법 섹션의 https://t4t5.github.io/sweetalert/ 에 있습니다.
당신은 확인 버튼을 숨기고 싶은 특정한 '방법'이 없고 단지 제안을 찾고 있기 때문에, 당신은 항상 그것을 목표로 하고 그것을 제공하기 위해 작은 CSS를 사용할 수 있습니다.display: none;
세우다.
원하는 위치에서 아래 줄의 코드를 사용하여 달콤한 경고를 표시하는 전류를 닫을 수 있습니다.
swal.close();
바로 그거야!
달콤한 개체 위에 닫기 방법을 사용할 수 있습니다. 아래 부분의 설명서를 참조하십시오.
https://t4t5.github.io/sweetalert/
swal.close(); --> 현재 열려 있는 SweetAlert를 프로그래밍 방식으로 닫습니다.
self.showProgress = function(message) {
swal({ title: message });
swal.showLoading();
};
self.hideProgress = function() {
swal.close();
};
swal2를 사용하는 경우 다음을 사용하여 닫을 수 있습니다.Swal.close()
아약스가 완료되면 코드 안의 어느 곳에서라도 코드를 닫을 수 있습니다. 아래 코드는 쉬운 방법이라고 생각합니다.
$(document).ajaxComplete(function () {
Swal.close();
});
SweetAlert는 http://t4t5.github.io/sweetalert/ 에서 문서를 확인하면 종료 방법이 있습니다.
사용할 수 있습니다.SweetAlert.close()
각진 상태에서 달콤한 경고를 닫습니다.
swal
에서 작동하지 않음sync
함수(예:get
), 통화가 필요합니다.get
비동기의
swal({
type: 'warning',
text: 'Please wait.',
showCancelButton: false,
confirmButtonText: "ok",
allowOutsideClick: false,
allowEscapeKey: false
}).then(function (result) {
if (result) {
setTimeout(function () {
$http.get(url)
}, 500);
}
});
Angular를 사용하는 경우각도-스위트 경보로 알려진 JS 라이브러리는 swal.close();를 사용하여 경보 창을 닫습니다. 각도-스위트 경보는 코어 스위트 경보 라이브러리 패키지의 래퍼입니다.
캐시 더swal()
그것을 나중에 촉발시키기 위해.
function GetDataFromServer(url) {
let swalAlert = SweetAlert.swal; // cache your swal
swalAlert({
title: "",
text: "Please wait.",
imageUrl: "../../app/app-img/loading_spinner.gif",
showConfirmButton: false
});
return $http.get(url)
.then(success)
.catch(exception);
function success(response) {
swalAlert.close(); // this is what actually allows the close() to work
return response.data;
}
function exception(ex) {
return (ex);
}
}
언급URL : https://stackoverflow.com/questions/44973038/how-to-close-sweet-alert-on-ajax-request-completion
'programing' 카테고리의 다른 글
HTML5 입력 유형 범위 범위 값 표시 (0) | 2023.08.15 |
---|---|
유형 오류: p.easing[this.easing]이(가) 함수가 아닙니다. (0) | 2023.08.15 |
테두리 반지름(%)(%) 및 픽셀(px) 또는 em) (0) | 2023.08.15 |
함수의 PowerShell 변수 증가 (0) | 2023.08.15 |
스팬 요소의 줄 바꿈 방지 (0) | 2023.08.15 |