Oscar Jara
Oscar Jara

Reputation: 14187

<p:dialog closeable="false"> still get closed on pressing Esc

I am using PrimeFaces 2.1 to show a dialog like this:

<p:dialog header="Test" modal="true" showEffect="fade" hideEffect="fade" widgetVar="dlgTest" resizable="false" closable="false" width="500">
<!-- dialog content -->
</p:dialog> 

Everything is ok but I also want that the dialog can't be closed (thats why I used "closable" false)

The problem is: when the dialog appears and the user press ESC, the dialog gets closed (skipping the closable property)

Any idea to solve this or is it a bug of Primefaces? I think closable property just remove the (X) from the dialog and has no sense!

Just to know: I tried to use jQuery and restrict the ESC key evaluating the keychar (27) in the interface but it has no effect when the dialog appears (it works just for the interface body)

Thanks!

Upvotes: 1

Views: 5394

Answers (1)

Matt Handy
Matt Handy

Reputation: 30025

There is a closeOnEscape attribute for p:dialog which defaults to true.

Try the following:

<p:dialog header="Test" 
          modal="true" showEffect="fade" 
          hideEffect="fade" widgetVar="dlgTest" 
          resizable="false" closable="false" 
          closeOnEscape="false" width="500">
  <!-- dialog content -->
</p:dialog> 

Upvotes: 5

Related Questions