将散列过滤器传递给外部 link(类似于 Isotope 但自定义)

Pass hash filter to external link (like Isotope but custom)

示例: 如果用户点击某个页面中的特定 link,此 link 会将他重定向到特定区域中的过滤内容。

I try to build an custom isotope with simple hide and show classes but now I can not make my links connect with the filtered content of other page.
*The hash is correct but it does not show the filtered content. Probably I have to do something with onhashchange function. Thank you!

//Generate URL hash
$('.filter-list .cat-item').on('click', function(){
    var filterAttr = $(this).attr('data-filter');
    location.hash = "filter=" + encodeURIComponent(filterAttr);
});
//Generate URL hash
function getHashFilter(){
    var currentHash = location.hash.match( /filter=([^&]+)/i );
    var filterValue = currentHash && currentHash[1];
    return filterValue;
}
function onHashChange(){

    var hashFilter = getHashFilter();

   /* if ( hashFilter ) {
      $container.isotope({ filter: hashFilter });
    }
   */
}
onHashChange();
window.onhashchange = onHashChange;

Topic closed. Below the full set of code for custom isotope grid filter.

//redirect link with js external document
$("#menu-product").click(function(){ 
    window.location.href = "shops.php#filter=product"; 
});

if (location.hash == "#filter=product") 
{ 
    $(".shop").not(".product").hide(); 
}

$(document).ready(function(){
 $(".cat-item").click(function(){

   var value =  $(this).attr("data-filter");
   if(value == "all") {
     $(".shop").show();
   }
   else
   {
     $(".shop").not("."+value).hide();
     $(".shop").filter("."+value).show();
   }});
   //Active class
    $("ul .cat-item").click(function(){
        $(this).addClass("current").siblings().removeClass("current");
    });

}); 
//Generate URL hash
$('.filter-list .cat-item').on('click', function(){
    var filterAttr = $(this).attr('data-filter');
    location.hash = "filter=" + encodeURIComponent(filterAttr);
});

function getHashFilter(){
    var currentHash = location.hash.match( /filter=([^&]+)/i );
    var filterValue = currentHash && currentHash[1];
    return filterValue;
}

function onHashChange(){
    var hashFilter = getHashFilter();
}