Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个帖子循环,我使用无限滚动来分页。我使用 SimpleModal 调用每个帖子的完整帖子弹出窗口,但它仅适用于最初加载的帖子。无限滚动调用的任何帖子只需单击即可进入实际的帖子页面。为什么会这样?
那是因为您的 SimpleModal 函数应用于加载文档时页面上存在的所有帖子。
加载文档后,无限滚动事物将触发 ajax 请求并在页面上添加新帖子(摘录)。
您需要做的是将 SimpleModal 函数附加到将来注册的点击事件上。所以如果你有类似的东西:
$('.post').click(function(){ // show modal });
将其更改为
$('.post').on('click', function(){ // show modal });
我在这里假设这些脚本是 jQuery 插件。
看$.on()
$.on()