title: Change hash without triggering a hashchange event
body: <p>I'm using the hash to load content dynamically. To make the back button work I am capturing hash changes. However sometimes I need to change the hash without triggering the hash changed function (eg, when the page was redirected server side and I need to update the hash once the content has returned.)</p>
  
  <p>The best solution I have come up with is to unbind the hashchange event, make the change and then rebind it. However, as this happens asynchronously, I am finding that it rebinds too quickly and still catches the hash change.</p>
  
  <p>My solution at the moment is very poor: Rebinding in a setTimeout. Does anyone have a better idea?</p>
  
  <pre><code>    $(window).unbind( 'hashchange', hashChanged);
      window.location.hash  = "!" + url;
      setTimeout(function(){
          $(window).bind( 'hashchange', hashChanged);
      }, 100);
  </code></pre>
  
  <p><br></p>
  
  <p>Edit:<br>
  Amir Raminfar's suggestion prompted me to a solution that does not require a timeout.
  I added a class variable</p>
  
  <pre><code>_ignoreHashChange = false;
  </code></pre>
  
  <p>When I want to change the hash silently I do this:</p>
  
  <pre><code>_ignoreHashChange = true;
  window.location.hash  = "!" + url;
  </code></pre>
  
  <p>and the hash changed event does this :</p>
  
  <pre><code>function hashChanged(event){
      if(_ignoreHashChange === false){
          url = window.location.hash.slice(2);
          fetchContent(url);
      }
      _ignoreHashChange = false;
  }
  </code></pre>