Skip to content

Instantly share code, notes, and snippets.

@brianmaierjr
Last active November 19, 2023 00:54
Show Gist options
  • Save brianmaierjr/1d7cc65294ccae254ac40f2e8f0c96f6 to your computer and use it in GitHub Desktop.
Save brianmaierjr/1d7cc65294ccae254ac40f2e8f0c96f6 to your computer and use it in GitHub Desktop.
Filter MixItUp on load from hash in URL
// Setup MixItUp for card filtering
var mixer = mixitup('.program-card-container');
if ($('.program-card-container')) {
var container = $('.program-card-container')
var mixer = mixitup(container, {
callbacks: {
onMixStart: function(state, futureState) {
},
onMixEnd: function() {
container
.find('.card:visible:first')
.focus();
}
}
});
if (location.hash) {
var hash = location.hash.replace('#', '.')
var oldBtn = $('button.selected');
var newBtn = $("button").find("[data-filter='" + hash + "']");
mixer.filter(hash)
oldBtn.removeClass('selected');
newBtn.addClass('selected');
}
}
@OneMohrTime
Copy link

Thank the gods. Saved me so many hours.

@tomvisions
Copy link

Same. Found this after so many hours of trial and error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment