[Javascript] Stop button from firing

Michael Borchers list at tridemail.de
Thu Jan 31 08:52:30 CST 2008


I have a little script that creates new rows with prototype.
When constantely hitting the executing button some rows share the same index.

How can I make my script wait getting finished before getting fired again?

Thanks


function JSONAddIndexedRow(numRowsIndex, addToElement, JSONUrl, direction) {
 if($(numRowsIndex)) {
  var numRows = parseInt($F(numRowsIndex));
 }

 if(JSONUrl != '') {
  new Ajax.Request(JSONUrl + '?num_rows=' + numRows,
       {
        method:'post',
          onSuccess: function(JSON) {
         if(JSON != null) {
          var JSONRows  = JSON.responseText;

          if(direction == '') {
           direction = 'after';
          }

          if($(numRowsIndex).value = numRows+1) {
           if($(addToElement)) {
            switch(direction) {
             case 'after':
             new Insertion.After($(addToElement), JSONRows);
             break;

             case 'before':
             new Insertion.Before($(addToElement), JSONRows);
             break;

             case 'bottom':
             new Insertion.Bottom($(addToElement), JSONRows);
             break;

             case 'top':
             new Insertion.Top($(addToElement), JSONRows);
             break;
            }
           }
          }
         }
          }
       }
      );
 }
}



-- 
MfG
Michael Borchers
Tridem GmbH
http://www.tridem.de
mailto: borchers at tridem.de
Tel.: 0491 / 96 06 71 63
ICQ: 322766923
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20080131/fdcac592/attachment.htm>


More information about the Javascript mailing list