title: jQuery bind/unbind 'scroll' event on $(window)
body: <p>I have this function: </p>
  
  <pre><code>function block_scroll(key){
      if (key) {
          $(window).bind("scroll", function(){
              $('html, body').animate({scrollTop:0}, 'fast');
          });
      } else {
          $(window).unbind();
      }
  }
  </code></pre>
  
  <p>The first part works as it should, but when I later call block_scroll(false) - it's still blocking. Wat do?</p>
  
  <p><strong>RE-EDIT</strong>
  So as suggested I tried...</p>
  
  <pre><code>$(window).unbind("scroll");
  </code></pre>
  
  <p>...with some confusion. At first it didn't work - then it worked.</p>
  
  <p>Now I think it failed because I was scrolling the moment block_scroll(false) was called. I've tested this several times now. And yes, if I do nothing while the script runs and block_scroll(false) is called - it does work. But it doesn't if I'm scrolling when it's called.</p>