1

我几乎完成了创建下面的不倒翁主题。该主题使用无限滚动插件,这适用于不包含 Flash(照片、文本...)的帖子。视频和音频帖子使用 Flash,当无限滚动开始加载更多帖子时,它不会加载到 Flash 帖子中。我无法理解为什么,由于截止日期迫在眉睫,有人可以帮忙吗?

http://penguinenglishlibrary.tumblr.com/

4

2 回答 2

5

结果我需要遍历帖子并调用 tumblr api 来获取音频帖子的嵌入代码。

我已将代码放在下面,希望对某人有所帮助:

  1. 我在 tumblr 主题中有以下 html 代码:

    {块:帖子}

    <div id="{PostID}" class="posts {block:Photo}photo-post{/block:Photo} {block:Video}video-post{/block:Video} {block:Audio}audio-post{/block:Audio} {block:Photoset}photoset-post{/block:Photoset}">
    
  2. 然后在砌体的回调(见下文)中,我有以下代码:

    /* repair audio players*/
    $('.audioplayerinto').each(function(){
        var audioID = $(this).attr("id");
        var $audioPost = $(this);
        $.ajax({
            url: 'http://myblog.tumblr.com/api/read/json?id=' + audioID,
            dataType: 'jsonp',
            timeout: 50000,
            success: function(data){
    
                $audioPost.html(data.posts[0]["audio-player"]);
    
    
                /*
                $audioPost.append('\x3cdiv style=\x22background-color:white;height:30px\x22 class=\x22audio_player\x22\x3e' + data.posts[0]['audio-player'] +'\x3c/div\x3e');
                alert("It worked");
                */
            }
        }
    

回调代码如下所示:

if($content.infinitescroll) {

    $content.masonry({
        itemSelector: '.posts',
        //columnWidth: 235,
        isAnimated: true
    }),    
    $content.infinitescroll({
        navSelector    : 'div#pagination',  
        nextSelector   : 'div#pagination div#nextPage a', 
        itemSelector   : '.posts',
        loading: {
            finishedMsg: '',
            img: 'http://static.tumblr.com/dbek3sy/pX1lrx8xv/ajax-loader.gif'
        },
        bufferPx       : 500,
        debug          : false,
    },
    // call masonry as a callback.
    function( newElements ) {
于 2012-04-15T00:35:35.243 回答
2

当对下一页进行 ajax 调用时,会从请求中去除内联脚本标记。因此闪光灯无法工作的原因。

.find 方法在插件中使用,隐式地作为 .load 方法和回调阶段的一部分:

jquery:在 .find() 之后保留 <script> 标记

对您而言,最好的选择是隔离 JS 代码,查看 Flash 视频工作所需的内联 JS,这似乎是合理的。

于 2012-04-14T11:54:21.123 回答