本文介绍了在jQuery Cycle插件中单击时,暂时禁用下一个/上一个按钮(链接)(不一定是jquery循环问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在2秒内阻止点击链接.

I need to prevent link from being clicked for let's say 2 seconds.

以下是示例 http://jsbin.com/orinib/4/edit

当您查看渲染模式时,您会看到下一个和上一个链接.当您单击下一步"时,它会以良好的过渡进行滑动.但是,如果您单击多次,则不会发生过渡.但是我的问题是:这是如何防止大约2秒钟(或过渡发生的时间)单击下一个链接,以便无论发生何种过渡.这是我尝试使用的方法,但是没有用:

When you look at the rendered mode you see next and prev links. When you click next, it slides with a nice transition. However if you click multiple times there is no transition sort of, which is expected. But my question: is this how can I prevent clicking on the next link, for about 2 seconds (or what ever time it takes for transition to happen) so that no matter what transition will occur.This is what I tried to use, but did not work:

function(){
var thePreventer = false;
$("#next").bind($(this),function(e){
    if(!thePreventer){
        thePreventer = true;
        setTimeout(function(){
            thePreventer = false;
        }, 2000);
    }else{
        e.preventDefault();
    }
});

}

我从此处获得的信息"Disable"我点击后是否会暂时获得一个链接?我相信我无法用此代码达到这种效果(尽管它可以在其他链接上使用).我认为这是由于cycle-plugin拥有该链接的事实,并且我了解到我必须绑定/点击该插件的功能.请注意:该代码可能不起作用,我只是用它来表明我尝试了它,但是没有用,如果需要,您可以重复使用它,也可以自己给我自己的东西.

Which I got from here "Disable" a link temporarily when clicked? I think. I believe that i cannot achieve this effect with this code (although it works on other links). I believe this is due to the fact that cycle-plugin got a hold of that link, and I understand that I have to bind/tap-into this functionality of the plugin. Please note: that this code may not work I just used it to show that I tried it and it did not work, you can reuse it if you have to or give me your own stuff.

请帮助.

编辑:正如 mrtsherman 提出的这种简单而优雅的 ANSWER : http://jsfiddle .net/LCWLb .

EDIT:As mrtsherman proposed this simple yet elegant ANSWER: http://jsfiddle.net/LCWLb.

推荐答案

看看周期选项页面.有很多方法可以做到这一点.我会考虑在onPrevNextEvent上使用寻呼机事件.您可以分配一个回调函数.

Take a look at the cycle options page. There are a number of ways to do this. I would consider using the pager event onPrevNextEvent. You can assign a callback function.

$('#slideshow').cycle({
    pager:  '#nav',
    onPrevNextEvent: function(isNext, zeroBasedSlideIndex, slideElement)  {
        //disable controls
    },
    after: function(currSlideElement, nextSlideElement, options, forwardFlag) {
        //reenable controls
    }
});

这篇关于在jQuery Cycle插件中单击时,暂时禁用下一个/上一个按钮(链接)(不一定是jquery循环问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 14:54