這是一個測試頁面:http://masonry-test.tumblr.com/tumblr音頻/視頻播放器+砌體無限滾動
我使用jQuery砌體與tumblr無限滾動。除了音頻播放器,一切都很好。它們不會加載到第二頁上,而是顯示此消息[需要Flash 9才能收聽音頻。]。
做了一點研究,找到了解決辦法。一個here(this one too),這裏的the js從Mesh theme,這成功(行35)。
問題是我不知道在哪裏以及如何在我的代碼中實現它。我試過的每件事都沒有奏效,或者在砌體砌塊周圍留下了一點空隙。我的代碼:
$(document).ready(function() {
var $container = $('.row');
$container.imagesLoaded(function() {
$container.masonry({
itemSelector: '.post',
columnWidth: 1
});
});
$container.infinitescroll({
navSelector: '#page-nav',
nextSelector: '#page-nav a',
itemSelector: '.post',
loading: {
finishedMsg: "No more entries to load.",
img: "http://static.tumblr.com/7wtblbo/hsDlw78hw/transparent-box.png",
msgText: "Loading..."
},
debug: true,
bufferPx: 5000,
errorCallback: function() {
$('#infscr-loading').animate({
opacity: 0.8
}, 2000).fadeOut('normal');
}
},
function (newElements) {
//tried this but doesn't work
/* repair video players*/
$('.video').each(function(){
var audioID = $(this).attr("id");
var $videoPost = $(this);
$.ajax({
url: '/api/read/json?id=' + audioID,
dataType: 'jsonp',
timeout: 50000,
success: function(data){
$videoPost.append('\x3cdiv class=\x22video_player_label\x22\x3e' + data.posts[0]['video-player'] +'\x3c/div\x3e');
}
}
});
});
/* repair audio players*/
$('.audio').each(function(){
var audioID = $(this).attr("id");
var $audioPost = $(this);
$.ajax({
url: '/api/read/json?id=' + audioID,
dataType: 'jsonp',
timeout: 50000,
success: function(data){
$audioPost.append('\x3cdiv class=\x22audio_player\x22\x3e' + data.posts[0]['audio-player'] +'\x3c/div\x3e');
}
}
});
});
var $newElems = $(newElements).css({
opacity: 0
});
$newElems.imagesLoaded(function() {
$newElems.animate({
opacity: 1
});
$container.masonry('appended', $newElems, true);
});
});
$(window).resize(function() {
$('.row').masonry();
});
});
謝謝!忘了將{PostID}添加到html中。 D'哦!就實施而言,Burt更新了他的代碼,並且它正在爲我工作。這裏:http://stackoverflow.com/a/10158605/351320 – Barbara 2012-04-16 20:20:19