2012-04-25 56 views
1
function ReInitializeCyclePlugin() { 
    var el = $("#id"); 
    var eventobject = EVobject; 
    var IdToInitialize = $(eventobject.currentTarget).attr("id"); 

    /* here first we are detaching the cycle plugin */ 
    el.find("#" + IdToInitialize).cycle("destroy"); 

    /* cycle plugin reinitializes here */ 
    el.find("#" + IdToInitialize).cycle({ 
     fx: $("#cyclescroll").val(), 
     easing: $("#cyclebounce").val(), 
     speed: 1000, 
     timeout: 2000 
    }); 
} 

我只是想根据用户给定的输入动态地重新初始化循环插件,并且我正在通过上面的代码尝试这一点。但有一些问题,它不起作用。它'成功'销毁,但不是重新初始化。这里有什么问题?jquery动态初始化循环插件

回答

2

你试过把它们串在一起吗? http://jsfiddle.net/lucuma/NTB4s/

el.find("#" + IdToInitialize).cycle("destroy").cycle({ 
    fx: $("#cyclescroll").val(), 
    easing: $("#cyclebounce").val(), 
    speed: 1000, 
    timeout: 2000 
});