title: jQuery: combining hashchange with a click function
body: <p>I'm having some trouble getting the hashchange function to work how I want it to. I currently have a masonry grid of divs, with a clearing div after every row (of 4), which is hidden. Clicking on one of the divs shows the closest clearing div, appends the relevant content inside it and reloads the masonry around it. <br>
  This all works fine, but as I want to link to these divs that are being show from other pages I want to attach hashes to the functions. The hashes are being added to the URL, but if you load the URL it fails to run the function and show the relevant divs.<br>
  Here's a jsfiddle: <a href="http://jsfiddle.net/EV7yg/1/" rel="nofollow">http://jsfiddle.net/EV7yg/1/</a>
  <br>
  <br>jQuery:</p>
  
  <pre><code>$(document).ready(function () {
  $(window).hashchange( function(){
  
      $(".content-block-footer").click(function () {
  
          $('.content-block-preview').hide();
          var previewForThis = $(this).parent(".content-block-small").nextAll('.content-preview:first');
          var otherPreviews = $(this).parent(".content-block-small").siblings('.content-preview').not(previewForThis);
          otherPreviews
              .addClass('excluded') // exclude other previews from masonry layout
              .hide();
          previewForThis
              .removeClass('excluded')
              .append($('#content-preview' + $(this).attr('hook')).show())
              .hide()
              .delay(400)
              .fadeIn("slow");
          $('html, body').animate({ scrollTop: $(this).offset().top-95 }, 'slow');
          $('#block-wrap').masonry('reload');
      });
      });
  $(window).hashchange();
  });
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div id="block-wrap"&gt;
  
  &lt;div class="content-block-small" style="background-color: white;"&gt;
  &lt;div class="content-block-footer" hook="01"&gt;&lt;a href="#test01"&gt;READ MORE&lt;/a&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="content-block-small" style="background-color: white;"&gt;
  &lt;div class="content-block-footer" hook="02"&gt;&lt;a href="#test02"&gt;READ MORE&lt;/a&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="content-block-small" style="background-color: white;"&gt;
  &lt;div class="content-block-footer" hook="03"&gt;&lt;a href="#test03"&gt;READ MORE&lt;/a&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="content-block-small" style="background-color: white;"&gt;
  &lt;div class="content-block-footer" hook="04"&gt;&lt;a href="#test04"&gt;READ MORE&lt;/a&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  
  
  &lt;div class="content-preview excluded"&gt;
  &lt;/div&gt;
  
  
  &lt;div id="content-preview01" class="content-block-preview"&gt;
  CONTENT GOES HERE
  &lt;/div&gt;
  
  &lt;div id="content-preview02" class="content-block-preview"&gt;
  CONTENT GOES HERE
  &lt;/div&gt;
  
  &lt;div id="content-preview03" class="content-block-preview"&gt;
  CONTENT GOES HERE
  &lt;/div&gt;
  
  &lt;div id="content-preview04" class="content-block-preview"&gt;
  CONTENT GOES HERE
  &lt;/div&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>Is it possible to attach hashes to such click functions and link to these hashes from exterior pages (showing the relevant content)?</p>