title: javascript event sequence/hierarchy included file vs in-file
body: <p>I define the same listener on <code>document.ready</code> in both an external script file and in-file. I have one in a central external file because I'll always want to perform the delete when clicking an element with class <code>.delete</code>, but sometimes I also want to do some other stuff.</p>
  
  <pre><code>//script.js
  $(document).ready(function(){
      $('.delete').click(function(){
          //send AJAX delete
      });
  });
  
  //index.php
  &lt;script type="text/javascript"&gt;
      $(document).ready(function(){
          $('.delete').click(function(){
              var msg = "Are you sure you want to delete the &lt;?=$item?&gt;'"+$(this).attr("name")+"'?";
              if ( confirm(msg) ) {
                  removeDataTableRow( $(this)... );
              }//fi
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>The listener in the external js file fires before the in-file script's listener, but I want the opposite (and I want to cancel the second event from the external file if <code>confirm=false</code>).</p>
  
  <p>I thought of setting a variable in the in-file script and setting that variable in the external to know the result of the confirm, but the script in the external script still fires first, and as such the variable has not yet been properly defined :/</p>
  
  <p><strong>EDIT</strong>: I've read <a href="https://stackoverflow.com/questions/282245/">question 282245</a> which covers event precedence of different listeners, but not for occurrences of the <em>same</em> listener.</p>