Nivoslider 更新或重启甚至销毁
我在加载动态内容时尝试更新 nivoslider 时遇到一些问题。我需要做的是当我通过 AJAX 调用加载新内容时更新滑块。
所以基本上我有一个 div,它从函数 AJAX
调用中获取新数据,加载后我需要滑块重新初始化。
我现在做的是这样的:
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();
它有点工作,但旋转只卡在一张图片上,有时它就是不'负载。对此的任何帮助将不胜感激。
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.
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);
and then a call to $('#imageSlider').nivoSlider();
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了解决方案。我没有只替换里面的图像,而是替换了里面的html。就像制作了新的 nivoslider 内容一样,它对我有用。然后使用所有参数再次初始化 nivoslider
在 ajax 响应之后 -
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
After ajax response -