[wd_asp elements=’search’ ratio=’100%’ id=1]

Sweet Alert Tab key not working fix!

17th May 2017

Jquery - Forms-Posting

jquery icon

A problem can occur if you use a form and sweet alert together, the code below can be adjusted to overcome this fix

var previousWindowKeyDown = window.onkeydown;
swal({
title : "delete file?",
text : "Do you want to delete it?",
type : "warning",
showCancelButton : true,
confirmButtonColor : "#27C24C",
confirmButtonText : "Yes",
cancelButtonText : "No ",
closeOnConfirm : false,
closeOnCancel : false
}, function (isConfirm) {
window.onkeydown = previousWindowKeyDown;
if (isConfirm) {
swal('Great', 'Deleted :)', 'success');
} else { swal("Dont Worry", "File left alone", "success");

}
});

OR you can hash this…..

var myfocus=1;
$('body').keyup(function(e) {
var code = e.keyCode || e.which;
if (code == '9') {
if (myfocus==1) {

myfocus=2;
$('#priceform').focus();
}
else {

$('#feeform').focus();
myfocus=1;
}

}
});