Skip to content

Instantly share code, notes, and snippets.

@jonaslsl
Created January 19, 2015 11:59
Show Gist options
  • Save jonaslsl/7b70f31a3547785cbd21 to your computer and use it in GitHub Desktop.
Save jonaslsl/7b70f31a3547785cbd21 to your computer and use it in GitHub Desktop.
isotope nav filter
<script type="text/javascript">
//loading isotope
var $container = $('.inside_view');
$(window).load(function(){
$container.isotope({
itemSelector : '.image',
layoutMode : 'fitRows'
});
});
// filter items when filter link is clicked
$(".nav a").on("click", function () {
event.preventDefault();
var f = $(this).attr('id');
if(f == 'todos')
f = "*"; //changes filter to * - wich means show everything
else
f = '.' + f; //add a . to filter as a class
//aplies the filter
$container.isotope({ filter: f });
//changing active class
$(this).addClass('active');
$(this).siblings('.active').removeClass('active');
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment