title: Disable then re-enable click function jQuery
body: <p>I have a file upload system, after the upload button is clicked, the file is then uploaded through AJAX. While the file is uploaded I want to disable the click function that is on the "Select Images" button.
  Currently this is the click function on the file-selection button:</p>
  
  <pre><code>$(document).ready(function() {
      $("#file-button").click(function() {
          $('#file').trigger('click');
      });
  });
  </code></pre>
  
  <p>That works fine, but I want to disable the click function in the progress phase of the XmlHttpRequest, and then re-enable the click function when I get a 200 response from the server. I have tried <code>bind()</code> and <code>unbind()</code> and it works fine in Chrome, but in firefox, during the upload, the button cannot be clicked, which is what I want, and then after I get a response from the server the button is re-enabled, but in firefox two file-selection dialogue windows open at the same time. This is because of the function above, and me binding the function again using <code>bind()</code>. Does anyone have any suggestions on how to enable, then disable the button without re-entering the code (function) of the click event.</p>
  
  <p>Something like this would be preferable:</p>
  
  <pre><code>$('#file-button').disable();
  $('#file-button').enable();
  </code></pre>
  
  <p>I have tried the <code>on()</code> and <code>off()</code> and they do not seem to work either.</p>