如何控制动态添加到DOM的元素



这对我来说是一个相当严重的问题,因为如果它比使用简单的jquery或ajax代码花费更多,我不知道如何编程。

为了总结我的情况,首先,我首先说我正在使用一个名为XE的CMS,它与wordpress非常相似。(请参阅链接:https://github.com/xpressengine/xe-core即使文档不支持英语)

正如您所看到的,下面的链接是一个使用XE CMS构建的板。

http://lifeto.cafe24.com/xe/htmlcss

XE使用自己的$函数调用文档

例如,这是来自上面链接的页面i的代码,当点击每篇文章的标题时,它会打开一篇文章

<a href="{getUrl('document_srl',$document->document_srl, 'listStyle',
 $listStyle, 'cpage','')}"><strong>{$document->getTitle()}</strong></a>

一切都很好,直到我决定添加这个名为无限滚动js的ajax jquery插件。

http://www.infinite-scroll.com/

因为这个js插件将文章动态添加到DOM中,正如你在我的网站上看到的那样,当我点击缩略图时,除了第一篇文章之外,其他文章都不会打开。(它可能会打开层本身,但它没有提供CMS给出的确切文档地址-注意,如果你点击"3"项,它仍然会在div上显示"4"项)

下面是我使用的脚本:打开一个包含文章的层,关闭该层,并将内容(文章)加载到打开的层中。

jQuery('body').on('click', '.list_content_link', function() {
        jQuery('.list_content_container').toggleClass('show');

 jQuery.post('{getUrl('document_srl',$document->document_srl, 'listStyle', $listStyle, 'cpage','')}', function(pageContent) {
        jQuery(".loader_container").empty().html('<div class="loader"><div class="loader-inner line-scale-pulse-out-rapid"><div></div><div></div><div></div><div></div></div></div>');
    jQuery('.list_content').load('{getUrl('document_srl',$document->document_srl, 'listStyle', $listStyle, 'cpage','')} .board_container');
    });        
});
    jQuery('body').on('click', '.list_content_container', function() { jQuery('.list_content_container').removeClass('show');
});
});`

我已经向CMS的一位开发人员提出了这个问题,但他唯一说的是,这必须由完成

只使用JS的jQuery.post或jQuery.load,不使用php或XE特定的代码,因为"getUrl(…$document->document_srl…)"在服务器中被解释,客户端无法提供任何信息。

有人能看出我有什么问题吗?

如果你要求任何信息,我可以为你提供一劳永逸的解决这个问题。我将感谢你的帮助。谢谢

使用'document'代替'body'jQuery(document).on('event-name','.list_content_link',function()

最新更新