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 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据