jQuery UI dialog increasingly calling the submit callback
===

I took the JQuery UI dialog form sample from JQuery UI website.

Since I wanted that, once the dialog is opened and the form is displayed, that pressing the <ENTER> key submits the form, I added the following in the onReady() :


  $.extend($.ui.dialog.prototype.options, { 
      open: function() {
          var $this = $(this);

          // focus first button and bind enter to it
          $this.parent().find('.ui-dialog-buttonpane button:first').focus();
          $this.keypress(function(e) {
              if( e.keyCode == 13 ) {
                  $this.parent().find('.ui-dialog-buttonpane button:first').click();
                  return false;
              }
          });
      } 
  });

This does perfectly the trick (I mean the click() is triggered when it has to), but the following occurs :

When the form is first submited through a press on the <ENTER> key, the submission is performed once.

If I reopen the dialog, and submit it again with a press on the <ENTER> key, the form is submitted twice.

If I reopen the dialog, and submit it again with a press on the <ENTER> key, the form is submitted three times, and so on...

This can be tested with the following fiddle :
http://jsfiddle.net/fWW2E/

Let me add that doing so by clicking on the dedicated "Submit" button works properly, this fails only when pressing the <ENTER> key is involved.

Any ideas ?

Thank you !
