同位素-单选按钮+组合过滤器 [英] Isotope - Radio Buttons + Combination Filters
问题描述
我正在使用Isotope对WordPress帖子进行排序.
I'm working on sorting a collection of WordPress posts with Isotope.
我需要使用组合过滤器,将链接列表与一组单选按钮组合在一起.使用此示例( http://bit.ly/1Rgf45i ),我添加了单选按钮功能,并且我还找到了用于组合过滤器的示例( http://bit.ly/1VXbtug ),但我不明白如何结合两者.有人可以帮忙吗?查看开发者网站链接的评论-我没有足够的经验来发布第三个链接.谢谢!
I need to use combination filters, combining a list of links with a set of radio buttons. Using this example (http://bit.ly/1Rgf45i), i added the radio button capability, and I also found this example (http://bit.ly/1VXbtug) for the combination filters, but I don't understand how to combine the two. Can anyone help? See comment for a dev site link - I don't have enough experience to post a third link. Thanks!
推荐答案
您需要创建一个函数,该函数收集所有选定按钮的过滤器值,并在单击任何过滤器按钮时单击以调用它(在类似于$(this).addClass('selected')
的行之后) ).
You need create a function, which collect filter-values of all selected buttons, and call it on click on any filter-button (after line like $(this).addClass('selected')
).
我为您制作了代码示例,但也许必须为您的网站进行一些稍微的编辑.
I make code example for you, but maybe it must be edited slightly for your site.
function allfilters() {
buttonFilter = '';
$('.button.selected').each(function () {
if($(this).attr('data-filter')) {
buttonFilter += $(this).attr('data-filter');
}
});
$('.isotope').isotope({filter: buttonFilter});
}
对于这个脚本,我认为按钮"Everything"的数据过滤器值必须为空(而不是"*").
And for this script, i think data-filter value for button "Everything" must be empty (not "*").
这篇关于同位素-单选按钮+组合过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!