Nivoslider更新或重新启动,甚至损坏 [英] Nivoslider update or restart or even destroy

查看:139
本文介绍了Nivoslider更新或重新启动,甚至损坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图加载动态内容时更新nivoslider时,有一些问题。我需要做的是更新的时候我加载通过 AJAX 呼叫新内容的滑块。

I'm having some issues when trying to renew the nivoslider when loading dynamic content. What I need to do is update the slider when I load new content in through an AJAX call.

所以基本上我有一个div,获取新数据从一个函数 AJAX 通话,后负荷,我需要滑块重新初始化。

So basically I have a div that gets new data in from a function AJAX call and after the load I would need the slider to reinitialize.

我做的,现在是这样的:

What I do right now is this:

if ($('#imageSlider').find('div.nivo-slice').length > 0) {
    $('#imageSlider').data('nivoslider').stop();
    $('#imageSlider').removeData('nivo:vars');
    $('#imageSlider').removeData('nivoslider');
    $('#imageSlider').attr("class","");
    $('#imageSlider').attr("style","");
}

$('#imageSlider').html(newImages);

,然后调用 $('#imageSlider)nivoSlider();

这有点儿工作,但旋转卡上的一张照片只,有时它只是不加载。任何帮助将是很大的AP preciated。

It kinda works but the rotation gets stuck on one picture only and sometimes it just doesn't load. Any help on this would be greatly appreciated.

推荐答案

我找到了一个解决方案。相反,只更换图片里面我更换里面的html。因此,像取得了新的nivoslider的内容,它为我工作。话又说回来initlize nivoslider所有参数

I found a solution for that . Instead of replacing only images inside I replaced html inside . So like made new nivoslider content and it works for me. Then initlize again nivoslider with all parameters

Ajax响应后 -

After ajax response -

    j('.slider-wrapper').html('');
    j('.slider-wrapper').html(request); 

    j('#slider').nivoSlider({
        effect: 'fade', // Specify sets like: 'fold,fade,sliceDown'
        slices: 15, // For slice animations
        boxCols: 8, // For box animations
        boxRows: 4, // For box animations
        animSpeed: 5, // Slide transition speed
        pauseTime: 3000, // How long each slide will show
        startSlide: 0, // Set starting Slide (0 index)
        directionNav: true, // Next & Prev navigation
        directionNavHide: true, // Only show on hover
        controlNav: false, // 1,2,3... navigation
        controlNavThumbs: false, // Use thumbnails for Control Nav
        controlNavThumbsFromRel: false, // Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', // Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
        keyboardNav: true, // Use left & right arrows
        pauseOnHover: true, // Stop animation while hovering
        manualAdvance: false, // Force manual transitions
        captionOpacity: 0.8, // Universal caption opacity
        prevText: 'Prev', // Prev directionNav text
        nextText: 'Next', // Next directionNav text
        beforeChange: function(){}, // Triggers before a slide transition
        afterChange: function(){}, // Triggers after a slide transition
        slideshowEnd: function(){}, // Triggers after all slides have been shown
        lastSlide: function(){}, // Triggers when last slide is shown
        afterLoad: function(){} // Triggers when slider has loaded
});

这篇关于Nivoslider更新或重新启动,甚至损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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