问题
I have a sweet alert with a textarea on it, the window is closing on spacebar press.
swal({
title: 'Something Went Wrong',
text: '<textarea id="my-textarea" name="my-textarea" rows="5" />',
type: 'error',
showCancelButton: true,
confirmButtonText: 'Yes, Refresh Page',
confirmButtonClass: 'btn-danger',
html: true
}
Can I prevent this behaviour ?
回答1:
I had the same problem and i solved it like this : If you use le min js, retrieve this part of code in sweet-alert.min.js "=n.keyCode||n.which,a=k(m,"visible");if(-1!==[9,13" and remove the next "32" in the array which represant the ascii code of spacebar.
回答2:
I have comment line 388 and was able to have the window not closing.
//fireClick($targetElement, e);
来源:https://stackoverflow.com/questions/34684404/sweet-alert-closing-on-spacebar-press