1

According to jQuery Mobile's documentation:

"Clicking the link that opened the panel, swiping left or right, or tapping the Esc key will close the panel. (...) By default, panels can also be closed by clicking outside the panel onto the page contents."

http://api.jquerymobile.com/panel/

The same documentation shows how to turn off "swipe to close" and "close by clicking outside".

But how to disable closing by the Esc key?

chapulina
  • 45
  • 2
  • 7

1 Answers1

0

You could do something like this:

$("body").on("keyup", function(e){
    if (e.which === 27){
        return false;
    } 
});

This will disable the escape key from closing a panel when one is open. This might interfere with other functions, and you probably could specify what element you want the event attached to. You can read more on return false here.

I made a very simple and lazy example of it working.

Community
  • 1
  • 1
Charlie
  • 11,380
  • 19
  • 83
  • 138
  • I wanted to disable it so I can use it for something else, and I was afraid that doing something like this would ruin my other function. But actually it didn't since I have another listener there :) Thanks – chapulina Jan 22 '14 at 17:18
  • You could also remove the functionality right from jQM, if you were so daring. – Charlie Jan 22 '14 at 19:54