Jquery 循环和 Ajax 字幕

发布于 2024-10-22 22:59:55 字数 884 浏览 8 评论 0原文

我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

咽泪装欢 2024-10-29 22:59:55

onBefore 应在设置 .cycle({}) 参数之前定义。

var ajaxcycle = function(){ 
    var onBefore = function(){
        $(".caption").empty().html("Opposite: " + this.alt);
    };

    $("#full-wrap").cycle({ after: onBefore });
};

onBefore should be defined before you set the .cycle({}) parameters.

var ajaxcycle = function(){ 
    var onBefore = function(){
        $(".caption").empty().html("Opposite: " + this.alt);
    };

    $("#full-wrap").cycle({ after: onBefore });
};
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文