Sweetalert: μžλ™ λ‹«κΈ° λ‹¬μ½€ν•œ κ²½κ³  방지

에 λ§Œλ“  2015λ…„ 05μ›” 10일  Β·  7μ½”λ©˜νŠΈ  Β·  좜처: t4t5/sweetalert

κ°„λ‹¨ν•œ 일을 ν•˜λ €κ³  ν•©λ‹ˆλ‹€. μ‚¬μš©μžκ°€ 확인 λ²„νŠΌμ„ 클릭할 λ•ŒκΉŒμ§€ νŒμ—…μ„ λ‹«κ³  싢지 μ•ŠμŠ΅λ‹ˆλ‹€(이 μ˜΅μ…˜μ„ κ»μ§€λ§Œ νŒμ—…μ΄ 계속 λ‹«νž™λ‹ˆλ‹€). λ‚΄ μ½”λ“œλŠ” λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€.

sweetAlert({
    title: "Hello",
    text: "<button type='button' class='btn btn-fb fb-share'>Share on Facebook</button>",
    type: null,
    confirmButtonText: "Close",
    html: true,
    closeOnConfirm: false, //It does close the popup when I click on close button
    closeOnCancel: false,
    allowOutsideClick: false
});

$(document).on( "click",".fb-share",  function(e){
    //here sweet alert closes when I press this button. 
    openFbPopup(); 
});

λ‹¬μ½€ν•œ μ•Œλ¦Όμ΄ λ‹«νžˆμ§€ μ•Šλ„λ‘ ν•˜λ €λ©΄ μ–΄λ–»κ²Œ ν•©λ‹ˆκΉŒ?

κ°€μž₯ μœ μš©ν•œ λŒ“κΈ€

λ‚˜λŠ” 이것이 λŠ¦μ—ˆλ‹€λŠ” 것을 μ•Œκ³  μžˆμ§€λ§Œ λ―Έλž˜μ— λˆ„κ΅°κ°€λ₯Ό λ„μšΈ 수 μžˆμŠ΅λ‹ˆλ‹€

@moazam1 μ˜΅μ…˜μ΄ λ‹€μŒμœΌλ‘œ λ³€κ²½λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

swal({
  closeOnClickOutside: false,
});

https://sweetalert.js.org/docs/#closeonclickoutside

λͺ¨λ“  7 λŒ“κΈ€

저도 이것에 λ¬Έμ œκ°€ μžˆλŠ” 것 κ°™μŠ΅λ‹ˆλ‹€. allowOutsideClick을 false둜 μ„€μ •ν•œ κ²½μš°μ—λ„ μ—¬μ „νžˆ 닫을 수 μžˆμŠ΅λ‹ˆλ‹€.

@moazam1 νŠΉμ • κ²½μš°μ—λŠ” μ˜΅μ…˜ 객체 λ‹€μŒμ— μΆ”κ°€ λ§€κ°œλ³€μˆ˜λ‘œ μ½œλ°±μ„ μˆ˜ν–‰ν•΄μ•Ό ν•©λ‹ˆλ‹€.

sweetAlert({
    title: "Hello",
    text: "<button type='button' class='btn btn-fb fb-share'>Share on Facebook</button>",
    type: null,
    confirmButtonText: "Close",
    html: true,
    closeOnConfirm: false, //It does close the popup when I click on close button
    closeOnCancel: false,
    allowOutsideClick: false
}, function () {});

$(document).on( "click",".fb-share",  function(e){
    //here sweet alert closes when I press this button. 
    openFbPopup(); 
});

아무 것도 ν•  ν•„μš”κ°€ μ—†μ§€λ§Œ λ‹€μŒκ³Ό 같은 κΈ°λŠ₯을 μ‚¬μš©ν•©λ‹ˆλ‹€.

function (isConfirm) {
   // ... Rest of code
}

μˆ˜λ™μœΌλ‘œ μ‘λ‹΅ν•˜κ³  λ‹€λ₯Έ μž‘μ—…μ„ μˆ˜ν–‰ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

마치 ν•Έλ“€λŸ¬κ°€ μ—†λŠ” κ²ƒμ²˜λŸΌ, 그렇지 μ•ŠμœΌλ©΄ μ–΄λ–»κ²Œ κ²½κ³ λ₯Ό 닫을 κ²ƒμž…λ‹ˆκΉŒ?

액컀 νƒœκ·Έλ₯Ό μ‚¬μš©ν•˜λŠ” 경우 λ™μΌν•œ νŽ˜μ΄μ§€λ‘œ λ¦¬λ””λ ‰μ…˜ν•˜λ―€λ‘œ href=""λ₯Ό μ œκ±°ν•˜λ©΄ λ©λ‹ˆλ‹€. κ·Έλž˜μ„œ κ²½κ³ κ°€ 슀슀둜 λ‹«ν˜”μŠ΅λ‹ˆλ‹€.

λ‚˜λŠ” 이것이 λŠ¦μ—ˆλ‹€λŠ” 것을 μ•Œκ³  μžˆμ§€λ§Œ λ―Έλž˜μ— λˆ„κ΅°κ°€λ₯Ό λ„μšΈ 수 μžˆμŠ΅λ‹ˆλ‹€

@moazam1 μ˜΅μ…˜μ΄ λ‹€μŒμœΌλ‘œ λ³€κ²½λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

swal({
  closeOnClickOutside: false,
});

https://sweetalert.js.org/docs/#closeonclickoutside

이것은 μž‘λ™ν•˜μ§€ μ•Šμ•˜μŠ΅λ‹ˆλ‹€.

@moazam1 덕뢄에 μ €μ—κ²Œ 도움이 λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

@moazam1
$(λ¬Έμ„œ).on( "클릭",".fb-곡유", κΈ°λŠ₯(e){
여기에 e.preventDefault()λ₯Ό μΆ”κ°€ν•΄μ•Ό ν•©λ‹ˆλ‹€.
μ˜€ν”ˆFbνŒμ—…();

그것은 λ‚˜λ₯Ό μœ„ν•΄ μΌν–ˆμŠ΅λ‹ˆλ‹€.
});

이 νŽ˜μ΄μ§€κ°€ 도움이 λ˜μ—ˆλ‚˜μš”?
0 / 5 - 0 λ“±κΈ‰