【发布时间】:2016-02-24 22:05:20
【问题描述】:
我已设置 Isotope 来过滤我的 wordpress 页面上的一些帖子。现在动画工作正常,类/数据过滤器命名相同,但我似乎无法让它工作。 Show all 按钮效果很好,但对于其他类别,所有帖子都会消失,而不是保留正确类名的帖子。我已经尝试记录我所有的 js 变量,据我所知,它们似乎是正确的。有人知道为什么这不起作用吗?
http://codepen.io/kathryncrawford/pen/WwevaG
JS
$(function ($) {
var $container = $('.js-grid'); //The class for the list with all the case studies
$container.isotope({ //Isotope options, 'item' matches the class in the PHP
itemSelector : '.js-case-item',
layoutMode : 'vertical'
});
//Add the class selected to the item that is clicked, and remove from the others
var $optionSets = $('.js-filter-container'),
$optionLinks = $optionSets.find('a');
$optionLinks.click(function(){
var $this = $(this);
// don't proceed if already selected
if ( $this.hasClass('js-selected') ) {
return false;
}
$optionSets.find('.js-selected').removeClass('js-selected');
$this.addClass('js-selected');
//When an item is clicked, sort the items.
var selector = $(this).attr('data-filter');
$container.isotope({ filter: selector });
});
});
【问题讨论】:
标签: jquery wordpress jquery-isotope