加载无限滚动页面时加载页面的CSS会发生变化
问题描述:
我在我正在构建的这个站点上有.mb_miniplayer_play的名称的Infinite Scroll,Isotope和一个音频播放器。我遇到的问题是,当一个新的页面加载时,以前加载的页面上的CSS改变。比方说,第2页被加载,第1页的CSS变化。但它只是一个元素。加载无限滚动页面时加载页面的CSS会发生变化
我已经尝试了各种各样的东西,但似乎没有使所有的页面看起来和正常工作。
的代码如下:
**//Audio jquery**
$(function AudioEvents(){
$(".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);
AudioEvents($newElements);
// add hover events for new items
bindSquareEvents($newElements);
setTimeout(function() {
$container.isotope('insert', $newElements);
}, 1000);
});
});
有没有人经历过这个。我认为我的jQuery代码是不正确的或缺少的东西,但我不知道是什么。
这是HTML标记...正在改变的div是.download。加载页面上的'Top'的css设置需要使其看起来正确:顶部:-114,而新加载的页面只需要顶部:-24以正确显示。
<div class="square techno">
<!-- DJ Picture -->
<img src="Pictures/dirtyharris.jpg" class="img1" />
<div class="boxtop">
<span class="genre">Techno</span>
</div>
<div class="box">
<a class="close" href="#close">×</a>
<!-- DJ Name -->
<h1> ThreeSixty & Dirty Harris</h1>
<!-- Song Title -->
<h2>Louka (Funkagenda Re-Edit)</h2>
<!--Song Description(179 characters with spaces)-->
<h4>I had to include this one since it literally took over control of me while driving the other morning. I was bouncing around in my seat like a little kid who desparately needs to use the bathroom. </h4>
<div class="buttons">
<!--Song file info-->
<div class="player">
<a id="m85" 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/ThreeSixty, Funkagenda - Loudka (Funkagenda Re-Edit).mp3" title='Right Click and Save Link As'>
<img src="img/dlicon.png"/></a>
</div>
</div>
</div>
</div>
答
我没有看到在jQuery中对CSS做任何更改。基于页面,CSS本身不会动态改变样式。当然,它可以被Jquery或php操纵,但我没有看到这一点。
我发现我使用回调的方式存在问题。 css并没有改变,它实际上是将另一个玩家放在现有玩家的顶部,结果将div降低到视线之外。研究为什么回调不能正常工作。 – user1063192 2012-01-19 03:45:16