2016-03-15 62 views

回答

1

同位素不会做到这一点本身,你必须找到自己的解决方案。从本机API过滤方法可以帮助你,但你必须提供

例如,如果您要筛选拥有一类像“冷”

  1. 你可以创建一个接受一个页面元素参数名为过滤 - 例如:http://www.yourdomain.com/page.html?filter=cold
  2. 你要拦截从Javascript的查询字符串,用一个简单的函数发现here并将其存储在一个querystringValue瓦里能够。

    var querystringValue = getParameterByName('filter');

  3. 一旦同位素被加载并准备 - 与所有元素,每一个拿着自己的过滤器类 - 你 可以使用过滤方法,通过您收到的查询字符串进行过滤。我会假定$ grid包含对网格对象的引用。

    $ grid.isotope({filter:querystringValue});

这只是其中一种可能性,但它的工作原理。您当然应该编写一个机制来处理无效的可能过滤器的查询字符串参数。

希望你觉得这个有用。

1

该解决方案的工作100%

例如

,如果你想通过从不同势网页过滤器类然后写出如下 http://www.dotsdesign.tv/ipltest/rs-mobile-plinth.php#infographic

的同位素本页面 http://www.dotsdesign.tv/ipltest/rs-case-studies-grid.php

<ul class="filters"> 
    <li class="filter selected"><a href="#" data-filter="*">All</a></li><br> 
    <li class="filter"><a href="#" data-filter=".isotope-category- 
    infographic">Infographic</a></li> 
    <li class="filter"><a href="#" data-filter=".isotope-category- 
    motiongraphic">Motion graphic</a></li> 
</ul> 

<ul id="portfolio" class="masonry-grid "> 
    <li class="masonry-grid-item isotope-category-infographic">infographic 
    data</li> 
    <li masonry-grid-item isotope-category-motiongraphic>motion graphic 
    data</li> 
</ul> 

现在在jquery中写下如下代码:

$(window).load(function(){ 
    var hashID = window.location.hash.substring(1); 

    /*$container is an isotope container.it may be different 
    a container is a wrapper for filter data 
    here is masonry-grid is a container*/ 

    $container.isotope({ filter: ".isotope-category-"+hashID }); 

    /*other filter selected logic you can apply to your HTML structure here*/ 

});