Isotope - Radio Buttons + Combination Filters

2019-09-11 11:53发布

问题:

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 "*").