title: Javascript sequential execution after trigger
body: <p>I'm having trouble with the way javascript execute the code (async)</p>
  
  <p>I have this small piece of code that will trigger events and check the value of 'valid'.</p>
  
  <p>My problem is that 'valid' is always true when entering the if statement because the events have not finished processing yet :</p>
  
  <pre><code>valid = true;
  
  $(this).find('input').trigger('blur');
  //valid will be modified in the triggered events
  
  if(valid){
      //Do something
  }
  </code></pre>
  
  <p>So I'd like to wait till the events are finished to enter the statement, but trigger doesn't take a callback</p>
  
  <p>I have seen some questions about this already solved but I didn't understand them and how to implement them.</p>
  
  <p>What should I use to solve this ? </p>