title: Get click handler from element in JQuery
body: <p>How can I get a reference to the click handler of an element in JQuery?</p>
  
  <p>Here is what I am trying to do:</p>
  
  <p>Store the click handler,
  Change the click handler for the next click,
  Restore the original click handler</p>
  
  <pre><code>var originalClick = $(settings.currentTarget).click;
  $(settings.currentTarget).off("click");
  
  $(settings.currentTarget).click(function (e) {
      e.preventDefault();
      settings.model.modal.close();
  
      $(settings.currentTarget).off("click");
      $(settings.currentTarget).click(originalClick);
  });
  </code></pre>
  
  <p>The above code works the first time, however, when I click on the element again it fails:</p>
  
  <pre><code> Uncaught TypeError: Object [object HTMLAnchorElement] has no method 'on' 
  </code></pre>
  
  <p><strong>Update:</strong>
  <br />
  I now realize that this is a really bad design that I am trying to do.  I have resolved this issue by maintaining a visibility boolean in my viewmodel, if it is true, don't re-open the modal.</p>