Skip to content

Instantly share code, notes, and snippets.

@unconditional
Last active October 4, 2016 13:55
Show Gist options
  • Save unconditional/b2dfaaf9d45f09e30ebb to your computer and use it in GitHub Desktop.
Save unconditional/b2dfaaf9d45f09e30ebb to your computer and use it in GitHub Desktop.
mixItUp_filter_hash.js
jQuery(document).ready(function(){
if (window.location.hash) {
var hashdata = new Object();
jQuery.each(window.location.hash.replace(/^#/,'').split('&'), function(i, t){
var s = t.split('=');
hashdata[s[0].toLowerCase()] = s[1].toLowerCase();
});
var $filters = jQuery('div[id^="Filters"]').find('li');
// iterate hashes
jQuery.each( hashdata, function( key, value ) {
console.log("hash " + key + " : " + value);
// try this hash on each filter
$filters.each( function() {
var $t = jQuery(this);
var this_text = $t.text().toLowerCase();
console.log("check filter: " + this_text + " against " + hashdata[key]);
if ( this_text == hashdata[key] ) {
$t.click();
return false;
}
}); // $filters.each
}); // each hashdata
} // if window.location.hash
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment