Page 1 of 1
Closing dialog with esc key
Posted: 12 Jan 2012, 14:28
by melancos
I have just upgraded to version 3.0 from 2.2 and now the 'esc key' doesn't close a dialog component. I expected the same behaviour no matter the version.
Currently I am using JSF 2.0 with Mojarra 2.0.3 and Tomcat 6.0.28 as servlet container.
Is this a bug or am I doing something wrong?
Thanks very much in advance
Re: Closing dialog with esc key
Posted: 12 Jan 2012, 14:29
by cagatay.civici
It's gone in 3.
Re: Closing dialog with esc key
Posted: 12 Jan 2012, 14:47
by melancos
I appreciate your quick response, optimus.
I have read dialog is reimplemented as a native PrimeFaces component in this new version. Is it planned for future versions, or is it definetively gone?
Re: Closing dialog with esc key
Posted: 12 Jan 2012, 14:49
by cagatay.civici
It can be back but it is not in our immediate roadmap.
Re: Closing dialog with esc key
Posted: 12 Jan 2012, 14:55
by melancos
OK, I see
Anyway, thank you very much
Re: Closing dialog with esc key
Posted: 17 Jul 2012, 00:12
by csotolani
Code: Select all
function closeOnEscape() {
var closeable;
var indexHighest = 0;
jQuery(".ui-dialog.ui-widget.ui-widget-content.ui-overlay-visible").each(function() {
var indexCurrent = parseInt($(this).css("zIndex"), 10);
if (indexCurrent > indexHighest) {
indexHighest = indexCurrent;
closeable = this;
}
});
if (closeable != null) {
jQuery(closeable).removeClass('ui-overlay-visible').addClass('ui-overlay-hidden');
jQuery(closeable).css({'visibility':'', 'z-index':'', 'display':''});
var modal = '#' + jQuery(closeable).attr('id') + '_modal';
jQuery(modal).remove();
}
};
<p:hotkey bind="esc" handler="closeOnEscape();" />
Re: Closing dialog with esc key
Posted: 25 Jul 2012, 17:47
by csotolani
Code: Select all
<script type="text/javascript">
jQuery(document).keyup(function(e) {
if (e.keyCode == 27) { //esc
closeOnEscape();
}
});
</script>