javascript - In jQuery Isotope or Masonry, can I ignore an item? - Stack Overflow

I have this list of items I want to filter through:<ul id="container"><li class=&quo

I have this list of items I want to filter through:

<ul id="container">
    <li class="item filter">This is where I'd put my filters</li>
    <li class="item">Item 1</li>
    <li class="item">Item 2</li>
    <li class="item">Item 3</li>
</ul>

So then I want to execute it like so...

  $container.isotope({
    itemSelector : '.item'
  });

...but I want an option like ignore: '.filter'. Is something like that doable?

The whole goal is to put the filters inside the container, taking on the same styles and transitions.

I have this list of items I want to filter through:

<ul id="container">
    <li class="item filter">This is where I'd put my filters</li>
    <li class="item">Item 1</li>
    <li class="item">Item 2</li>
    <li class="item">Item 3</li>
</ul>

So then I want to execute it like so...

  $container.isotope({
    itemSelector : '.item'
  });

...but I want an option like ignore: '.filter'. Is something like that doable?

The whole goal is to put the filters inside the container, taking on the same styles and transitions.

Share Improve this question edited Oct 20, 2014 at 6:00 Sameera Thilakasiri 9,50810 gold badges53 silver badges87 bronze badges asked Oct 23, 2012 at 23:30 developdalydevelopdaly 1,3753 gold badges16 silver badges26 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7
$container.isotope({
    itemSelector : '.item:not(.filter)'
});

Simply use the :not() selector.

EDIT:

You suggest wanting to include it in the initial isotope selection, and for it to act as an item of the isotope, except not be filterable - at least this is how I am understanding you.
So to achieve this, keep your original:

$container.isotope({
    itemSelector : '.item'
});

And later, when you do your filters, simply always include , .filter
Example:

//Assume something got clicked, which had a data-filter attribute.
var filters = $(this).data('filter');
$container.isotope({
    filter: filters +', .filter'
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745201147a4616331.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信