JSFiddle - React, Tailwind, and code Playground

by BandonRandon

JavaScript

var $container = $('.sort-container');
$.getJSON('member-cat-json.php', function (data) {
    // I'm wrapping the isotop creation inside the `getJSON`
    // call, just to ensure that we have `data`

    $container.isotope({
        itemSelector: '.member-item',
        layoutMode: 'straightDown',
        getSortData: (function () {
            // We create this function and call it immediately    

            // It doesn't matter what this function does so long as it returns
            // an object with keys for each sort function

            var sortMethods = {};

            for (var index in data)
            var slug = data[index].slug;

            // immediately create the function to avoid
            // closure problems
            sortMethods[slug] = (function () {
                return function ($elem) {
                    return $elem.hasClass(slug) ? ' ' : '';
                };
            })();
        })

        return sortMethods;


    })();

});