我的网站是一个音乐网站,每页有 24 个单曲播放器。问题是播放器没有在新加载的页面上加载。
我在我的网站上使用无限滚动,我无法获得回调来处理我的无限滚动代码,所以根据我的研究,.live 是下一步要采取的措施。
不幸的是,我不知道如何在我的代码中实现 .live。我不确定它是否适用于这种情况。
有没有人有任何相关的例子,甚至可以帮助解决这种情况。
音频播放器代码如下:
//Audio jquery
$(function(){
$(".audio").mb_miniPlayer({
width:210,
height:34,
inLine:false,
onEnd:playNext
});
var $audios = $('.audio');
function playNext(idx) {
var actualPlayer=$audios.eq(idx),
$filteredAtoms = $container.data('isotope').$filteredAtoms,
isotopeItemParent = actualPlayer.parents('.isotope-item'),
isoIndex = $filteredAtoms.index( isotopeItemParent[0] ),
nextIndex = ( isoIndex + 1 ) % $filteredAtoms.length;
$filteredAtoms.eq( nextIndex ).find('.audio').mb_miniPlayer_play();
};
});
不确定这是否需要,但这里是无限滚动代码:
//Inifinite Scroll
var $container = $('#container');
$container.isotope({
itemSelector : '.square'
});
$container.infinitescroll({
navSelector : '#page_nav', // selector for the paged navigation
nextSelector : '#page_nav a', // selector for the NEXT link (to page 2)
itemSelector : '.square', // selector for all items you'll retrieve
loading: {
finishedMsg: 'No more pages to load.',
img: 'http://i.imgur.com/qkKy8.gif'
}
},
// call Isotope as a callback
function( newElements ) {
var $newElements = $(newElements);
// add hover events for new items
bindSquareEvents( $newElements );
setTimeout(function() {
$container.isotope('insert', $newElements );
}, 1000);
});
分区示例:
<div class="square pop">
<!-- DJ Picture -->
<img src="Pictures/adrianlux.jpg" class="img1" />
<div class="boxtop">
<span class="genre">Pop</span>
</div>
<div class="box">
<a class="close" href="#close">×</a>
<!-- DJ Name -->
<h1>Adrian Lux</h1>
<!-- Song Title -->
<h2>Alive (Extended Mix)</h2>
<!--Song Description(179 characters with spaces)-->
<h4>Although this is not truly a pop song, I don't think it can be classified as anything else. The transition from spoken-word lyrics to rising vocals is wonderful as is the drop that follows.</h4>
<div class="buttons">
<!--Song file info-->
<div class="player">
<a id="m75" class="audio {skin:'#010101',showVolumeLevel:false,showTime:false,showRew:false,ogg:'MP3/Adrian Lux feat. The Good Natured - Alive (Extended Mix).ogg'}" href="MP3/Adrian Lux feat. The Good Natured - Alive (Extended Mix).mp3"></a></div>
<!--Download Link-->
<div class="download">
<a href="MP3/Adrian Lux feat. The Good Natured - Alive (Extended Mix).mp3" title='Right Click and Save Link As'>
<img src="img/dlicon.png"/></a>
</div>
</div>
</div>
</div>