Board index JavaServer Faces General Closing dialog with esc key

Closing dialog with esc key

Components, Ajax Framework, Utilities and More.

Post 12 Jan 2012, 14:28

Posts: 3
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

Post 12 Jan 2012, 14:29

Posts: 15036
Location: Cybertron

It's gone in 3.
PrimeFaces Lead

Post 12 Jan 2012, 14:47

Posts: 3
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?

Post 12 Jan 2012, 14:49

Posts: 15036
Location: Cybertron

It can be back but it is not in our immediate roadmap.
PrimeFaces Lead

Post 12 Jan 2012, 14:55

Posts: 3
OK, I see :(

Anyway, thank you very much

Post 17 Jul 2012, 00:12

Posts: 4
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();" />

Post 25 Jul 2012, 17:47

Posts: 4
<script type="text/javascript">
jQuery(document).keyup(function(e) {
if (e.keyCode == 27) { //esc
closeOnEscape();
}
});
</script>


Return to General