0

我使用 fieg 的 jquery.ias.js,它有一个函数“onRenderComplete”。你可以在github 链接上得到这个

我有一个文章列表,其中加载新项目效果很好。但是每个生成快速视图的项目都有一个脚本部分

$("p.ex-[ID]").click(function(){
        $(".express-[ID] .top").delay(500).load("/[Name4URL]/a-[ID]/ .express");
        $(".express-[ID] .bottom-ex .ex-desc").delay(500).load("/[Name4URL]/a-[ID]/ #tab1.tab_content");
        $(".express-container-[ID]").fadeIn(500);

        window.setTimeout(function() {
            MagicZoomPlus.refresh("Zoomer2");
            $(".mz-thumbs a:gt(3)").addClass("nope");
            $(".mz-thumbs a:gt(7)").addClass("nope2");

            $(".image-container .mz-thumbs a:eq(3)").addClass("no-margin-right no-margin-top");
            $(".image-container .mz-thumbs a:eq(7)").addClass("no-margin-right");
            $(".image-container .mz-thumbs a:eq(0)").addClass("no-margin-top");
            $(".image-container .mz-thumbs a:eq(1)").addClass("no-margin-top");
            $(".image-container .mz-thumbs a:eq(2)").addClass("no-margin-top");
        }, 1200); 
    });



    $(".express-container-[ID] .close").click(function(){
        $(".express-[ID] .top").load("/[Name4URL]/a-[ID]/ .clear");
        $(".express-[ID] .bottom-ex .ex-desc").load("/[Name4URL]/a-[ID]/ .clear");
        $(".express-container-[ID]").fadeOut(500);
    });

对于未加载的项目,这很好用。但是新加载的项目没有触发。这是 jquery.ias 部分:

$(document).ready(function() {
jQuery.ias({
    container : ".container",
    item: ".item",
    pagination: ".articlePages",
    next: 'a .next',
    loader: '<img src=/layout/cyt/img/ajax-loader.gif"/>',
    triggerPageThreshold: 1,
    history: false,
    onRenderComplete: function(items) {


    }
});
});

我试图将脚本部分实现到 onRenderComplete 函数中,但它不起作用,我真的不知道该怎么做。

4

1 回答 1

0

我相信你应该使用 jquery .on() 方法http://api.jquery.com/on/。click 方法不适用于动态插入的 DOM 元素。你应该这样做:

$("selector-that-contains-p.ex-[ID]").on("click", "p.ex-[ID]", function() {// do the stuff
});
于 2013-09-09T15:32:02.010 回答