Isotope - Radio Buttons + Combination Filters

不问归期 提交于 2019-12-11 23:08:35

问题


I'm working on sorting a collection of WordPress posts with Isotope.

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!


回答1:


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});
}

And for this script, i think data-filter value for button "Everything" must be empty (not "*").



来源:https://stackoverflow.com/questions/33181535/isotope-radio-buttons-combination-filters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!