title: submit form using mootools
body: <p>I have made a class that handles load and submit of a html form. See code below</p>
  
  <pre><code>ND.Form = new Class({
      //--- Implements options og events.
      Implements: [Options, Events],
  
      //--- Options.
      options: {
          url: '',
          injectTo: ''
      },
  
      //--- Initialize the class.
      initialize: function (panel, options) {
          //--- Set options
          this.setOptions(options);
          this.panel = panel;
          this.loadForm();
      },
  
      loadForm: function () {
          var req = new Request.HTML({
              url: this.options.url,
              method: 'get',
              onSuccess: function (html) {
                  $(this.options.injectTo).empty();
                  $(this.options.injectTo).adopt(html);
                  var formId = $(this.options.injectTo).getFirst('form').get('id');
                  $(formId).addEvent('submit', function (e) {
                      e.stop();
                      this.submitForm(formId);
                  } .bind(this));
              } .bind(this)
          }).send();
      },
  
      submitForm: function (formId) {
          $(formId).set('send', {
              onSuccess: function (resp) {
                  this.panel.loadContent();
                  if (resp != null) {
                      $('lbl_error').empty();
                      $('lbl_error').setStyles({ 'display': 'block', 'color': 'red' }).set('html', resp);
                  }
              }.bind(this),
  
              onFailure: function (resp) {
                  if (resp != null) {
                      $('lbl_error').empty();
                      $('lbl_error').setStyles({ 'display': 'block', 'color': 'red' }).set('html', resp);
                  }
              }
          });
          $(formId).send();
      }
  });
  </code></pre>
  
  <p>And it all works just fine, exept that when i push the save button more than ones the "this.panel.loadContent();" in the "submitForm: function (formId)" fires the same x amount of times I have pushed the button, how can i prevent this ?</p>
  
  <p>/Martin</p>