title: Confirm Jquery UI Dialog Prompt on Enter Key
body: <p>I've tried the techniques suggested in the following stack answer to no luck:</p>
  
  <p><a href="https://stackoverflow.com/questions/868889/submit-jquery-ui-dialog-on-enter">Submit jQuery UI dialog on &lt;Enter&gt;</a></p>
  
  <p>Something must be off with my code. On login, I have a disclaimer that pops up to warn the user that the information found within the site is confidential. I would like it so that to continue, all the user has to do is hit the enter key. Here is my original code (I've included a browser check):</p>
  
  <pre><code>  $("#loginForm").submit(function (e) {
      e.preventDefault();
  
      if ($.browser.msie) {
          $("#dialog-confirm")
          .dialog({
              resizable: false,
              height: 300,
              width: 550,
              modal: true,
              buttons: {
                  "Continue": function (e) {
                      $("#loginForm").unbind('submit').submit(),
                      $(this).dialog("close"),
                      $("#loginForm").submit();
                      $("#btnLogin").click();
                  },
                  Cancel: function (e) {
                      e.preventDefault();
                      $(this).dialog("close");
                  }
              }
  
          })
      }
      else {
          $("#dialog-browser")
          .dialog({
              resizable: false,
              height: 220,
              width: 480,
              modal: true,
              buttons: {
                  "Close": function (e) {
                      e.preventDefault();
                      $(this).dialog("close");
                  }
              }
          })
      };
  });
  </code></pre>
  
  <p>Now here is my code with the keyup commands: </p>
  
  <pre><code>$("#loginForm").submit(function (e) {
      e.preventDefault();
  
      if ($.browser.msie) {
          $("#dialog-confirm")
          .dialog({
              resizable: false,
              height: 300,
              width: 550,
              modal: true,
              buttons: {
                  "Continue": function (e) {
                      $("#loginForm").unbind('submit').submit(),
                      $(this).dialog("close"),
                      $("#loginForm").submit();
                      $("#btnLogin").click();
                  },
                  Cancel: function (e) {
                      e.preventDefault();
                      $(this).dialog("close");
                  }
              },
    HERE&gt;&gt;&gt;      open: function() { 
                  $("#dialog-confirm").keypress(function(e) { 
                    if (e.keyCode == $.ui.keyCode.ENTER) { 
                      $("#loginForm").unbind('submit').submit(),
                      $(this).dialog("close"),
                      $("#loginForm").submit();
                      $("#btnLogin").click(); 
                    } 
                  }); 
                } 
          })
      }
      else {
          $("#dialog-browser")
          .dialog({
              resizable: false,
              height: 220,
              width: 480,
              modal: true,
              buttons: {
                  "Close": function (e) {
                      e.preventDefault();
                      $(this).dialog("close");
                  }
              }
          })
      };
  });
  </code></pre>
  
  <p>This unfortunately is not working for me and I can't for the life of me figure out why? If anyone can see where the issue is, I'd be extremely grateful!</p>
  
  <p>Thanks!!</p>