目前正在构建一个使用 Desandro 的 jQuery Masonry 并内置 Infinite Scroll 的站点。在除 IE 之外的所有浏览器中都能出色地工作(即使 IE7 和 IE8 也能正常工作)。看来 jQuery(function) 根本没有执行。我已经通过在内部放置警报进行了测试,但从未执行过。IE Developer 中没有显示错误。
这是我的代码和网站链接:http ://www.elke.co/testimonials/
<script type="text/javascript">
jQuery(function () {
var $container = jQuery('#sort');
$container.imagesLoaded(function () {
$container.masonry({
itemSelector: '.box',
columnWidth: 100
});
});
$container.infinitescroll({
navSelector: '.navigation', // selector for the paged navigation
nextSelector: '.navigation .nav-previous a', // selector for the NEXT link (to page 2)
itemSelector: '.box', // selector for all items you'll retrieve
loading: {
finishedMsg: 'No more pages to load.',
img: 'http://www.elke.co/wp-content/themes/shaken-grid-free/images/ajax-loader.gif'
}
},
// trigger Masonry as a callback
function (newElements) {
// hide new items while they are loading
var $newElems = jQuery(newElements).css({
opacity: 0
});
// ensure that images load before adding to masonry layout
$newElems.imagesLoaded(function () {
// show elems now they're ready
$newElems.animate({
opacity: 1
});
$container.masonry('appended', $newElems, true);
});
});
});
</script>