tumblr喜欢按钮不是无限滚动阿贾克斯召回工作后, [英] Tumblr like button not working after infinite scroll ajax recall

查看:254
本文介绍了tumblr喜欢按钮不是无限滚动阿贾克斯召回工作后,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有几个类似的职位,但他们是有相当过时,据我所知的tumblr已经更新了API的一部分,就像不久以前。

There are a few similar posts but they are quite out of date and Tumblr has updated the like part of the API not too long ago as far as I'm aware.

创建一个像按钮一样简单
    {} LikeButton

Creating a like button is as simple as {LikeButton}

和这个伟大的工程,但AJAX回忆摆脱这将是下一个页面的更多帖子后,类似按钮不再起作用。

and this works great, but after the ajax recalls to get more posts from what would be the next page, the like button no longer works.

我有看文档和它说我需要实现,我想知道如果任何人都可以在正确的方向指向我下面的一个?我一直试图让这几个小时的工作。

I have had a look at the documentation and it states that I need to implement one of the following, I was wondering if anyone could point me in the right direction? I've been trying to get this to work for hours.

我做了一个例子博客,如果这有利于提高接听时,JavaScript可以做的新图像执行的质量数量。

I made up an example blog if this helps contribute to answering, the javascript can do the mass amount of the implementing of new images.

http://stackoverflowexample.tumblr.com/

如果你需要的信息了,我会高兴地编辑这个并添加的需要什么,谢谢!

If you need anymore info, i'll happily edit this and add what's required, thank you!

推荐答案

从我的previous答案在这里适应:<一href=\"http://stackoverflow.com/questions/16390193/using-tumblr-like-button-with-infinite-scroll/16396022#16396022\">Using tumblr Like按钮与无限滚动

Overview

Adapted from my previous answer here: Using Tumblr Like Button with Infinite Scroll

的tumblr指出,我们需要调用两个函数之一获得的般的地位。我建议如下:

Tumblr states we need to call one of two functions to get the Like Status. I would suggest the following:

功能:Tumblr.LikeButton.get_status_by_post_ids([N,N,N])
  说明:要求如个别职位的状态。采用后一组ID

Function: Tumblr.LikeButton.get_status_by_post_ids([n,n,n]) Description: Request Like status for individual posts. Takes an array of post IDs

在Ajax请求是成功的,我们应该有一个数据对象(含新职位,等等)。

Once the ajax request is successful , we should have a data object (containing new posts, etc).

我们需要创建 postIDs 的数组,这是一个包含在数据每篇日志的ID /编号的数组对象。添加的帖子ID最简单的方法是使用主题变量 {}帖子ID

We need to create an array of postIDs, which is an array containing an ID / number for each post in the data object. Easiest way to add the the post id is to use the theme variable {PostID}.

<article class="post" id="{PostID}">...</article>

jQuery的帖子的ID阵列

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

Tumblr.LikeButton

Tumblr.LikeButton.get_status_by_post_ids($newPostIDs);

提示

创建数组并调用 Tumblr.LikeButton 一旦Ajax请求成功,在您运行新的帖子等功能的地方。这也可以与纯的JavaScript完成与使用:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map

Hints

Create the array and call Tumblr.LikeButton once the ajax request is successful and in a place where you run other functions for the new Posts. This can also be done with pure javascript as using: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map

这篇关于tumblr喜欢按钮不是无限滚动阿贾克斯召回工作后,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆