I am using JqModal in my project. Its a nice JS modal. However i need one help to attach an Close On Escape key press to the JqModal. I am loading eternal content from external URL in JqModal.
For simple Modal where no IFrame is used, its very easy to implement the CloseOnEscape key press feature.
I made it work by updating the jqModal.js file
Steps:
Add option "closeOnEsc: true" to the jqModal. So the option will look something like this,
var p = {
overlay: 50,
overlayClass: 'jqmOverlay',
closeClass: 'jqmClose',
trigger: '.jqModal',
ajax: F,
ajaxText: '',
target: F,
modal: F,
toTop: F,
onShow: F,
onHide: F,
onLoad: F,
closeOnEsc: true
};
Add following code to the jqModal open function.
var modal = $(h.w);
modal.unbind("keydown");
if (c.closeOnEsc) {
modal.attr("tabindex", 0);
modal.bind("keydown", function (event) {
if (event.keyCode == 27) {
event.preventDefault();
modal.jqmHide();
}
});
modal.focus();
}