我一直在尝试实现很棒的同位素插件http://isotope.metafizzy.co/index.html
我遇到了一个过滤器问题,到目前为止找不到解决方法:
发生的情况是,当单击“全部”过滤器链接时,会显示所有项目,但是当单击任何其他过滤器链接时,所有项目都会消失。我真的很感激一些帮助:)
我已经建立了一个JSFiddle
这是代码:
HTML:
<div class="large-12 columns">
<ul id="portfolio-filter">
<li><a href="#" data-filter="*">ALL</a></li>
<li><a href="#" data-filter=".website">WEBSITE</a></li>
<li><a href="#" data-filter=".logos">LOGOS</a></li>
<li><a href="#" data-filter=".illustrations">ILLUSTRATIONS</a></li>
<li><a href="#" data-filter=".brand">BRAND</a></li>
<li><a href="#" data-filter=".ui">UI</a></li>
<li><a href="#" data-filter=".icons">ICONS</a></li>
</ul>
<div id="portfolio-container">
<ul class="small-block-grid-2">
<li><div class="website"><a href="#"><img src="img/portfolio/small-01.jpg" alt=""></a></div></li>
<li><div class="logos"><a href="#"><img src="img/portfolio/small-02.jpg" alt=""></a></div></li>
<li><div class="illustrations"><a href="#"><img src="img/portfolio/small-03.jpg" alt=""></a></div></li>
<li><div class="brand"><a href="#"><img src="img/portfolio/small-04.jpg" alt=""></a></div></li>
<li><div class="ui"><a href="#"><img src="img/portfolio/small-05.jpg" alt=""></a></div></li>
<li><div class="icons"><a href="#"><img src="img/portfolio/small-06.jpg" alt=""></a></div></li>
<li><div class="website"><a href="#"><img src="img/portfolio/small-07.jpg" alt=""></a></div></li>
<li><div class="logos"><a href="#"><img src="img/portfolio/small-08.jpg" alt=""></a></div></li>
<li><div class="illustrations"><a href="#"><img src="img/portfolio/small-09.jpg" alt=""></a></div></li>
<li><div class="brand"><a href="#"><img src="img/portfolio/small-10.jpg" alt=""></a></div></li>
<li><div class="ui"><a href="#"><img src="img/portfolio/small-11.jpg" alt=""></a></div></li>
<li><div class="icons"><a href="#"><img src="img/portfolio/small-12.jpg" alt=""></a></div></li>
<li><div class="website"><a href="#"><img src="img/portfolio/small-13.jpg" alt=""></a></div></li>
<li><div class="logos"><a href="#"><img src="img/portfolio/small-14.jpg" alt=""></a></div></li>
<li><div class="illustrations"><a href="#"><img src="img/portfolio/small-15.jpg" alt=""></a></div></li>
<li><div class="brand"><a href="#"><img src="img/portfolio/small-16.jpg" alt=""></a></div></li>
</ul>
</div><!-- /portfolio-container -->
</div><!-- /large-12 columns -->
JavaScript:
$(document).ready(function(){
// cache container
var $container = $('#portfolio-container');
// initialize isotope
$container.isotope({
// options...
});
// filter items when filter link is clicked
$('#portfolio-filter li a').click(function(){
var selector = $(this).attr('data-filter');
$container.isotope({ filter: selector });
return false;
});
});