Jquery 循环和 Ajax 字幕
我使用 Jquery Cycle 淡化 Ajax 加载的一些图像,并使用插件中的 onBefore
选项显示相应图像的标题。褪色部分效果非常好。标题部分有点工作,只是不是只加载当前图像集的标题,而是加载每个图像转换之间的标题和闪烁随机标题属于先前加载的图像集的图像。
我尝试在插件选项中将标题加载设置为 before:
和 after:
,但没有成功,并且我尝试使用 .empty()
在加载新标题之前清除标题容器。还是不行。 Jquery Cycle 被称为我在 CMS 中使用的 Ajax 插件的成功函数;我猜测标题问题与多次调用 Jquery Cycle 有关,但即使在启动它的新实例之前销毁 Jquery Cycle 也无助于解决标题问题。这是我的 Jquery Cycle 函数的样子:
<!--calls jquery cycle after smd_ajax pulls in the content-->
function ajaxcycle(){
$('#full-wrap').cycle({
after: onBefore
});
function onBefore() {
$('.caption')
.empty()
.html('Opposite: ' + this.alt);
};
};
这是实时站点,以便您可以看到发生了什么事。任何帮助将不胜感激。
I'm using Jquery Cycle to fade some images being loaded by Ajax, and show a caption for corresponding images using the onBefore
option in the plugin. The fading portion of this is working fabulously. The caption portion is sort of working, only instead of loading just the captions for the current set of images, it loads the captions and between each image transition flashes a random caption for an image belonging to a previously loaded set of images.
I tried setting the caption loading to both before:
and after:
in the plugin options without luck, and I've tried using .empty()
to clear the caption container before loading a new caption. Still no good. Jquery Cycle is being called as the success function of the Ajax plugin I'm using with my CMS; I'm guessing the caption problem has something to do with Jquery Cycle being called multiple times, but even destroying Jquery Cycle prior to starting a new instance of it didn't help the caption problem. Here's what my Jquery Cycle function looks like:
<!--calls jquery cycle after smd_ajax pulls in the content-->
function ajaxcycle(){
$('#full-wrap').cycle({
after: onBefore
});
function onBefore() {
$('.caption')
.empty()
.html('Opposite: ' + this.alt);
};
};
And here's the live site so you can see what's happening. Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
onBefore
应在设置 .cycle({})
参数之前定义。onBefore
should be defined before you set the .cycle({})
parameters.