hgnl96
hgnl96

Reputation: 43

Shuffle.js function after Ajax call

I use this library: http://vestride.github.io/Shuffle/, works good, but the the problem I have now is, I have a load more button, for loading more images.

It is made with Ajax, but when I call the function again after the Ajax call, the grid is not updated:

$(document).ajaxComplete(function(){
    shuffleGrid();
});

My shuffleGrid function:

shuffleGrid = function(){
    var $grid = $('#block .content');

    $grid.shuffle({
        itemSelector: '.views-row'
    });
};

Upvotes: 0

Views: 1145

Answers (1)

hgnl96
hgnl96

Reputation: 43

Problem solved by do this:

$(document).ajaxComplete(function(){
    $('#block .content .views-row:not(.shuffle-item)').each(function() {
        var $newRow = $(this);

        $('#block .content').append($newRow);
        $('#block .content').shuffle('appended', $newRow);  
    });
});

Upvotes: 2

Related Questions