jquery动态初始化循环插件

时间:2012-04-25 10:31:43

标签: jquery jquery-plugins jquery-cycle

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

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

1 个答案:

答案 0 :(得分:2)

你试过将它们链接在一起吗? http://jsfiddle.net/lucuma/NTB4s/

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