0

我在一篇文章中创建了一个评论区,然后发表评论的会员名称会有一个链接,并且可以点击链接以使用facebox显示会员资料,问题是当另一个会员评论加载AJAX时,该链接无法正常使用 Facebox 显示会员资料。

会员名及链接:

<a href="/view/profile/<?php print $data['mId']; ?>/" title="View <?php print stripquote($data['mName']); ?>'s Profile" rel="facebox" class="membername"><?php print $data['mName']; ?></a>

加载更多评论按钮:

<a href="#" id="<?php echo $msg_id; ?>" class="more">Load more comment</a>

脸书配置:

jQuery(function($){
    $('a[rel*=facebox]').facebox();
});

那么,如何在使用 AJAX 加载更多成员评论后使 Facebook 正常工作。时间

4

1 回答 1

0

有几种方法可以解决这个问题。

您可以在 ajax 加载后设置 facebox 链接,例如

// I don't know how you're doing the ajax load, but say you were using jQuery #load
$(".more").click(function() {
  $("#yourdiv").load("something.php", function() {
     $(this).find("a[rel*=facebox]").facebox();
  });  
});

或者你可以变得更花哨,并在点击链接时懒洋洋地加载 Facebook,例如:

$(document).on("click", "a.facebox", function() {
  // I've never used facebox, but according to the docs (link below), this should work.
  $.facebox({ ajax: $(this).attr('href') });
});

请参阅文档中的以编程方式控制 Facebox

于 2012-11-29T05:33:09.157 回答