Hello, everyone.

I've got a function that is being called an additional time for each time a 
button is clicked, and I can't figure out where the loop that is causing it 
is.

HTML: 
<input name="btnRun" id="btnRun" type="button" value="Run">

JS:
if ($('btnRun')){
  $('btnRun').addEvent('click',function(){ *alert('This will only alert 
once.');*
    saveValues(function(){ *alert('this will alert once more for each 
button click'); *
      $('updateForm').storeOriginals();// quick save of form values to an 
array
      generateUpdates();
      });
    })
  }

function saveValues(andThen){
  $('updateForm').validate();
  fy = $('fy').get('value');
  if ($('updateForm').hasErrors()){ $('updateForm').showErrors();}
  else{
    var thisURL = "/fldr1/fldr2/update.cfc?method=update&fy=" + fy;
    $('updateForm').set('send', {
      url: thisURL,
      onComplete: function(json,text){
        json = JSON.decode(json);
        if(json == null){
          json = JSON.decode(text);
          }
        andThen();
        }
      }
    }
  }

Once the page loads, the first time the button is clicked each alert will 
show once.  If the page is not reloaded, but the button clicked a second 
time, the first alert will show once but the second alert will show twice.

If the page is not reloaded and the button clicked a third time, the first 
alert will show once, but the second alert will show three times, and so on.

The addEvent click is being called once, but the saveValues function is 
being called once more for each iteration.

Any thoughts appreciated,

JD

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"MooTools Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to