SweetAlert๊ฐ ์๋ฒฝํ๊ฒ ์๋ํ์ง๋ง ์ค๋ฅ๊ฐ ์์ต๋๋ค. ๋ถํธ์คํธ๋ฉ ๋ชจ๋ฌ์ ์ฌ์ฉํ๊ณ ์ด๋ ค ์๋ ๋์ SweetAlert๋ ์ฌ์ฉํฉ๋๋ค. SweetAlert์์ 'Cancel', 'OK'....๋ฅผ ํด๋ฆญํ๋ฉด 'Uncaught RangeError: Maximum call stack size included' ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค. ๋ฌธ์ ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
if (btnIndex === -1) {
// Something in the dom, but not a visible button. Focus back on the button.
$targetElement.focus();
}
์ด ์ฝ๋์ ์ฃผ์์ ๋ฌ๋ฉด ๋ ์ด์ ์ค๋ฅ๊ฐ ๋ฐ์ํ์ง ์์ต๋๋ค.
์ถ์ : ๋ชจ๋ฌ์ ์ด์ง ์์ผ๋ฉด ์ด ์ค๋ฅ๊ฐ ๋ฐ์ํ์ง ์์ต๋๋ค.
์ ๋ ์ด๋ฐ ์ค๋ฅ๊ฐ ์์์ต๋๋ค.
SweetAlert๊ฐ ๋ถํธ์คํธ๋ฉ ๋ชจ๋ฌ๊ณผ ์ถฉ๋ํ๊ธฐ ๋๋ฌธ์ (๋ถํธ์คํธ๋ฉ์) ์ด๋ฆฐ ๋ชจ๋ฌ์ด ์์ ๋ ๋ฌ์ฝคํ ๊ฒฝ๊ณ ๋ฅผ ํ์ํ๋ ค๊ณ ํ๋ ๊ฒ ๊ฐ์ต๋๋ค. ๋น์ ์ด ์ธ๊ธ ํ์ด ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ ๊ฒฝ์ฐ์
๋๋ค.
์ด๋ป๊ฒ ๋ (๊ธ์, ๋๋ ๋น์ ์ ์๊ตฌ ์ฌํญ์ด ๋ฌด์์ธ์ง ๋ชจ๋ฅด๊ฒ ๋ค) ๋จผ์ ๋ถํธ ์คํธ๋ฉ ๋ชจ๋ฌ์ ๋ซ์ ๋ค์ ๋ฌ์ฝคํ ๊ฒฝ๊ณ ๋ฅผ ํ์ํด์ผํฉ๋๋ค. ๊ทธ๋ฆฌ๊ณ ๊ด์ฐฎ์ ๊ฒ๋๋ค.
@littleneotrix ๊ฐ์ฌํฉ๋๋ค. ์ ํํ๋ ๋ถํธ์คํธ๋ฉ ๋ชจ๋ฌ์ด ์ด๋ ค ์๊ณ ์๋ฃจ์ ์ด ์์ ํ ์๋ํ๋ ๋์ ๋ฌ์ฝคํ ๊ฒฝ๊ณ ๋ฅผ ํ์ํ๋ ค๊ณ ํ์ง๋ง ๋ด ์ฑ์์๋ ๊ทธ๋๋ก ๋์ด์ผ ํ๊ธฐ ๋๋ฌธ์ ์ฝ๋์ ์ฃผ์์ ๋ฌ์์ผ ํ์ต๋๋ค.
๊ธ์, ๋น์ ์ ๊ทธ๊ฒ์ ์กฐ๊ธ ์๋ํ๊ณ ์ฌ์ํ ์ ์์ต๋๋ค ...
Sweetalert๋ฅผ ์ด๊ธฐ ์ง์ ์ Javascript๋ฅผ ์ฌ์ฉํ์ฌ ๋ถํธ์คํธ๋ฉ ๋ชจ๋ฌ์์ .hide()๋ฅผ ์ฌ์ฉํ๋ฉด ๋ฉ๋๋ค.
๊ทธ๋ฆฌ๊ณ ๋์์ผ Sweetalert๋ฅผ ์ด์ง๋ง ์ด๋ ์ ๋ ๊ทธ๋ ๊ฒ ํ์ญ์์ค.
swal({ title: "Are you sure?", text: "Your will not be able to recover this imaginary file!", type: "warning", showCancelButton: true, confirmButtonColor: "#DD6B55", confirmButtonText: "Yes, delete it!", closeOnConfirm: false }, function(){ $('#myModal').modal('show')});
๊ฐ์ฒด ๋์ ์๋ ํจ์์์ ๋ณผ ์ ์๋ฏ์ด ๋๋ ๊ทธ์๊ฒ ๋ชจ๋ฌ์ ๋ค์ ๋ฌป๋๋ก ์ง์ํฉ๋๋ค.
๊ทธ๋์ ... ๋จผ์ ๋ชจ๋ฌ์ ์จ๊ธฐ๊ณ -> sweetalert ํ๋กฌํํธ -> sweetalert์ ํ์ธ์์ ๋ชจ๋ฌ์ ๋ค์ ํ๋กฌํํธํ์ญ์์ค.
๊ทธ๊ฒ์ด ๋ด๊ฐ ์ ๊ณตํ ์ ์๋ ์ต๊ณ ์ ์๋ฃจ์
์
๋๋ค ;)
๋ฌผ๋ก ๋ถํธ์คํธ๋ฉ์ด ์ด ๋ฌธ์ ๋ฅผ ์์ ํ์ง ์๋ ํ.
๊ฐ์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค. ์ด๊ฒ์ ๋ถํธ์คํธ๋ฉ ๋๋ sweetalert ๋ฌธ์ ์ ๋๊น? ์ ๊ฒฝ์ฐ์ ๊ฒฝ๊ณ ๋ฉ์์ง๋ sweetalert์ ์ํด ์์ฑ๋์ง๋ง ๋ถํธ์คํธ๋ฉ์ผ๋ก ์ธํด ๋ฐ์ํ ์ ์์ต๋๋ค.
๋๋ ๊ฐ์ ์ค๋ฅ๊ฐ์๋ค
์ ๊ฒฝ์ฐ์๋ ๋ชจ๋ฌ์ ๋ฒํผ์ด ์์ผ๋ฉฐ ๋ฒํผ์ ํญ๋ชฉ์ ์ญ์ ํ๋ ๊ฒ์ ์๋ฏธํฉ๋๋ค. ํด๋ฆญํ๋ฉด swal์ ์ฌ์ฉํ์ฌ ํ์ธํฉ๋๋ค. ์ด ์์ ์์๋ ์ค๋ฅ๊ฐ ์์ง๋ง ๊ณ์ ์งํํ๊ณ '์ทจ์' ๋๋ 'ํ์ธ' ๋ฒํผ์ ํด๋ฆญํ๋ฉด ์ค๋ฅ.
์ง๊ธ์ ๋ถํธ์คํธ๋ฉ์ ๊ฒฝ๊ณ ํด๋์ค๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ ์ฐ๊ธฐํ๋ฉด์ ์ด ๋ฌธ์ ๋ ๋ฐ์ํฉ๋๋ค.
๋๋ ๊ฐ์ ๋ฌธ์ ์ ๋ถ๋ชํ ์ ์ ํ ์ฒ๋ฆฌ ๋ฐฉ๋ฒ์ ์๊ฐํด ๋์ต๋๋ค. ๊ธฐ๋ณธ์ ์ผ๋ก ๋ชจ๋ฌ์ ์จ๊ธฐ๊ณ swal์ ํ์ํ๊ณ ํ์ธ ์ ๋ชจ๋ฌ์ ๋ค์ ๊ฐ์ ธ์ต๋๋ค. ์๋ฅผ ๋ค์ด ํ๋ ํ์ ์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ์ฝ๋๋ ๋ค์๊ณผ ์ ์ฌํฉ๋๋ค.
$('.mfp-wrap').hide();
swal({
title: "Updated!",
text: "#" + data.updateData['number'] + " was successfully updated",
type: "success"
},
function(isConfirm) {
$('.mfp-wrap').show();
});
์ด๊ฒ์ ๊ธฐ๋ณธ์ ์ผ๋ก @littleneotrix ๊ฐ ๋งํ ๊ฒ์ ๋๋ค. ๋๋ ์ฒ์์ ๊ทธ์ ์ค๋ช ์ ์ดํดํ์ง ๋ชปํ๊ณ ๋ ์์ธํ ์๋ฅผ ๋ค์ด์ผ๊ฒ ๋ค๊ณ ์๊ฐํ์ต๋๋ค. ๋ด ์ฌ์ฉ ์ฌ๋ก์ ๋ํด ์ถฉ๋ถํ ์ฐ์ํ ์๋ฃจ์ ์ด๋ผ๊ณ ์๊ฐํฉ๋๋ค.
์ง๋ฌธํ๋ ์ฌ๋๋ค์๊ฒ ๊ฐ๋ฐ์๊ฐ ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด ํ ์ ์๋ ์ผ์ ๋ง์ง ์๋ค๊ณ ์๊ฐํฉ๋๋ค. ์ด์ค ๋ชจ๋ฌ๊ณผ ์ฝ๋ฐฑ์ ๋ฌด๊ฒ์ต๋๋ค.
์๋ฃจ์
์ด ์์ต๋๋ค.
์ฃผ์:
$targetElement.focus ();
_์๋ง๋ 413๋ฒ ์ค์._
๊ทธ๋ฅ ์ถ๊ฐ $.fn.modal.Constructor.prototype.enforceFocus = function () {};
ํธ์ถํ๊ธฐ ์ ์ swal(...);
ํ๋์ ๋ฌธ์ ๋ก ์ ์งํฉ์๋ค: https://github.com/aspnetboilerplate/aspnetboilerplate-templates/issues/48
SweetAlert 2.0์์ ๋ค์ ์๋ํด ๋ณด์ญ์์ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์๋ฃจ์ ์ด ์์ต๋๋ค.
์ฃผ์:
$targetElement.focus ();
_์๋ง๋ 413๋ฒ ์ค์._