Dojo likes to trap events, as such the current way to disable the escape key for dialogs is to use dojo.stopEvent(evt) …

 

   1:  dojo.connect(dijit.byId("disclaimer_dialog").containerNode, 'onkeypress', function(evt) {
   2:              key = evt.keyCode;
   3:              if (key == dojo.keys.ESCAPE) {
   4:                  console.debug("Escape trapped !!")
   5:                  dojo.stopEvent(evt);
   6:              }
   7:          });

 

I’m starting to feel like there is “the dojo way” and them um…expected way…

Maybe I just missed it but why isn’t there a property for “disableEscape” or “allowEscape” …whatever…it works right…

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

  2 Responses to “disable escape key in dijit.Dialog / dojo dialog”

  1. Hi Eric, thank you so much, I almost eat my hat with the escape key. To copy your code I had to view the page source code because it doesn’t appears very well on browser.

  2. good way!

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

   
© 2012 eric.polerecky.com Suffusion theme by Sayontan Sinha