Ajax调用后的Shuffle.js函数 [英] Shuffle.js function after Ajax call

查看:101
本文介绍了Ajax调用后的Shuffle.js函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用此库: http://vestride.github.io/Shuffle/,有效很好,但是我现在遇到的问题是,我有一个加载更多"按钮,用于加载更多图像.

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.

它是用Ajax制作的,但是当我在Ajax调用之后再次调用该函数时,网格不会更新:

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

我的shuffleGrid函数:

My shuffleGrid function:

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

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

推荐答案

解决此问题的方法:

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

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

这篇关于Ajax调用后的Shuffle.js函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆