weixin_33724059 2011-03-17 18:58 采纳率: 0%
浏览 33

jQuery周期和Ajax字幕

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.

  • 写回答

1条回答 默认 最新

  • weixin_33671935 2011-03-17 19:06
    关注

    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 });
    };
    
    评论

报告相同问题?

悬赏问题

  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法