Last active
November 19, 2023 00:54
-
-
Save brianmaierjr/1d7cc65294ccae254ac40f2e8f0c96f6 to your computer and use it in GitHub Desktop.
Filter MixItUp on load from hash in URL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Same. Found this after so many hours of trial and error.