νμΈ λ²νΌμ λν μ½λ°± 맀κ°λ³μκ° μμ§λ§ μ·¨μ λ²νΌμ λν μ½λ°±μ μ΄λ»κ² μ¬μ©ν μ μμ΅λκΉ?
μ½λμ doneFunction
맀κ°λ³μκ° μμ΅λλ€.
μ΄ μ½λλ₯Ό μλνκ³ μμ§λ§ λ΄ μ½λ°±μ΄ μμ ν 무μλ κ² κ°μ΅λλ€. λ΄κ° λ μλͺ»νκ³ μμ΅λκΉ?
(new Promise((resolve, reject) => {
swal({
title: "Delete data?",
text: "Deleted data will be lost.",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Delete",
closeOnConfirm: false,
html: false,
doneFunction(res) {
if (res) {
resolve();
} else {
reject();
}
}
});
})).then(() => console.log("Resolved"), () => console.log("Rejected"))
μ μκ²λ λ§μ°¬κ°μ§μ λλ€. λ΄ μ½λ°± ν¨μλ νμΈ λ²νΌμ ν΄λ¦νλ©΄ νΈμΆλμ§λ§ μ·¨μ λ²νΌμ νΈμΆλμ§ μμ΅λλ€.
@jeffmath λλ κ·Έκ²μ ν΄κ²°νκΈ° μν΄ https://github.com/limonte/sweetalert2 λ‘ μ ννμ΅λλ€.
λ¬Έμμμ μ΄ μμ μ μννλ λ°©λ²μ μλ₯Ό μ°Ύμ μ μμ΅λλ€. http://t4t5.github.io/sweetalert/
"... 맀κ°λ³μλ₯Ό μ λ¬νλ©΄ 'μ·¨μ'μ λν΄ λ€λ₯Έ μμ μ μ€νν μ μμ΅λλ€."
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel plx!",
closeOnConfirm: false,
closeOnCancel: false
},
function(isConfirm){
if (isConfirm) {
swal("Deleted!", "Your imaginary file has been deleted.", "success");
} else {
swal("Cancelled", "Your imaginary file is safe :)", "error");
}
});
@t4t5 isConfirmμ ν΅ν΄ μ¬μ©μ μλ΅μ΄ νμΈ λ²νΌμΈμ§ μλλ©΄ λ€λ₯Έ νλͺ©μΈμ§ νμΈν μ μμ΅λλ€. κ·Έλ¬λ ν΄λ¦ν λ²νΌμ΄ "νμΈ" λ²νΌμΈμ§ "μ·¨μ" λ²νΌμΈμ§ "λ«κΈ°" λ²νΌμΈμ§ νμΈνλ λ°©λ²μ μλ €μ£Όμ€ μ μμ΅λκΉ? μ·¨μ λ²νΌμ μ¬μ©νμ¬ λ€λ₯Έ κ³³μΌλ‘ 리λλ μ νμ§λ§ λ«κΈ° λ²νΌμ κ²½κ³ λ₯Ό λ«μ λΏμ΄κΈ° λλ¬Έμ λλ€.
μ€μ λ¬Έμ λ sweetalert v1.xμμ μ·¨μ μ²λ¦¬κΈ°κ° function(
https://github.com/t4t5/sweetalert/blob/v1.1.3/lib/modules/handle-λ‘ μμνλ μ½λ°±μ νμΈνλ€λ κ²μ
λλ€.
λ°λΌμ ν΄λΉ μ‘°κ±΄μ΄ μΆ©μ‘±λμ§ μμΌλ©΄ @Zorgatone μ μμ μμ doneFunction(
νλ―λ‘ μ½λ°±μ 무μλ©λλ€.
μ’μ μΊμΉ @gualopezb. λλ μ΄κ²μ μμν μλ μμΌ°κ³ κ°μκΈ° μλμ λ©μ·μ΅λλ€.
λ₯΄ μμ :
- }, (code) => {
+ }, function(code) {
λ΄ Babel ꡬμ±μ μ½κ°μ λ³κ²½μ΄ μλ κ² κ°μ΅λλ€.
κ°μ₯ μ μ©ν λκΈ
λ¬Έμμμ μ΄ μμ μ μννλ λ°©λ²μ μλ₯Ό μ°Ύμ μ μμ΅λλ€. http://t4t5.github.io/sweetalert/
"... 맀κ°λ³μλ₯Ό μ λ¬νλ©΄ 'μ·¨μ'μ λν΄ λ€λ₯Έ μμ μ μ€νν μ μμ΅λλ€."