Closed r2edwin closed 7 years ago
You're looking at the wrong end of things. The issue is because the user's focus is still on the button or element that was clicked to create the popup. You just need to focus on something else or blur the focus. I thought I had added that to the code already, but it's really simple for you to do. Right after you popup the alert...try $('body').focus(); or something like that.
Or try $('.your-btn-element').blur();
Hi. I' m using jAlert-functions.js wich redefines the -alert- native function. But if I hit Enter or Spacebar when the alert is on screen, it fires the alert again and I need to press Escape key many times to close them. I' ve made a few modification to the jAlert.js and could solve the "Enter key problem". This are my modifications:
Line 157 approximately: closeAlert: function(remove, onClose) { if( remove != false ) { remove = true; } / add this / $(document).off('keydown', $.fn.jAlert.onEnter);
Line 277 if( alert.video && alert.video.indexOf('youtube.com/watch?v=') > -1 && alert.video.indexOf('embed') === -1 ) { alert.video = alert.video.replace('watch?v=', 'embed/'); } / add this / if( alert.type == 'modal' ) $(document).on('keydown', $.fn.jAlert.onEnter);
Line 860: / Keydown on document (escape key) / $.fn.jAlert.onEscKeyDown = function(e){ ,,,,original code here }
i've tried to do the same with the spacebar key but I could not do it. Any ideas ? Thanks in advance