gpt4 book ai didi

javascript - Ajax 加载后 Tumblr 之类的按钮不起作用

转载 作者:行者123 更新时间:2023-12-03 10:10:45 24 4
gpt4 key购买 nike

我在我的 tumblr 主题中使用 pjaxmasonry。我刚刚弄清楚如何在单击 pjax 链接后让砌体正常工作,但现在的问题是“喜欢”按钮不再起作用。这是到目前为止我的代码:

html:

<article class="entry" id="{PostID}">

</article>

jquery:

$(document).ajaxComplete(function(){
$('#content').imagesLoaded(function(){
$('#content').masonry('reloadItems').masonry();
});

var $newPosts = $(data).find('.entry');
var $newPostIDs = $newPosts.map(function () {
return this.id;
}).get();

Tumblr.LikeButton.get_status_by_post_ids($newPostIDs);
});

最佳答案

我相信您需要使用pjax:success。这将为您提供 data 对象。

$(document).on('pjax:success', function( event, data, status, xhr, options ) {

$('#content').imagesLoaded(function(){
$('#content').masonry('reloadItems').masonry();
});

var $newPosts = $(data).find('.entry');
var $newPostIDs = $newPosts.map(function () {
return this.id;
}).get();

Tumblr.LikeButton.get_status_by_post_ids($newPostIDs);

});

来源:https://github.com/defunkt/jquery-pjax#events

关于javascript - Ajax 加载后 Tumblr 之类的按钮不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30120195/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com