Infinite scroll breaks flash

谁说胖子不能爱 提交于 2019-12-04 20:59:16

Turns out I needed to loop through the posts and call the tumblr api to get the embed code for the audio post.

I have put the code in below hopefully it will help someone:

  1. I have the folowing html code in the tumblr theme:

    {block:Posts}

    <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. Then inside the callback (see below) for masonry I have the following code:

    /* 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");
                */
            }
        }
    

The callback code looks like:

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 ) {
trickyzter

When the ajax call is made to the next page, inline script tags are stripped out of the request. Hence the why the flash won't work.

The .find method is used within the plugin, implicitly as part of the .load method and callback phase:

jquery: Keep <script> tag after .find()

The best option for you is to isolate the JS code, having looked at the inline JS required for the flash video to work, this seems plausible.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!