Javascript 使用jQuery更改$sign
我正在尝试使用无限卷轴制作砖石结构,我找到了官方的Javascript 使用jQuery更改$sign,javascript,jquery,jquery-masonry,infinite-scroll,Javascript,Jquery,Jquery Masonry,Infinite Scroll,我正在尝试使用无限卷轴制作砖石结构,我找到了官方的附加的方法(),并尝试在我的代码中使用它。但是我需要将一些$更改为jQuery,现在它可以用作砖石,但infinte滚动仍然不起作用,我想知道我是否忘记了一个美元符号从我的代码更改为jQuery,请帮助我 <script > jQuery(function(){ var $container = jQuery('ul.products'); $container.imagesLoaded(function(){
附加的方法(),并尝试在我的代码中使用它。但是我需要将一些$
更改为jQuery
,现在它可以用作砖石,但infinte滚动仍然不起作用,我想知道我是否忘记了一个美元符号从我的代码更改为jQuery
,请帮助我
<script >
jQuery(function(){
var $container = jQuery('ul.products');
$container.imagesLoaded(function(){
$container.masonry({
itemSelector: 'li.product',
columnWidth : 295,
isFitWidth: true,
gutterWidth : 2
});
});
$container.infinitescroll({
navSelector : '#page-nav-woo', // selector for the paged navigation
nextSelector : '.next', // selector for the NEXT link (to page 2)
itemSelector : 'li.product', // selector for all items you'll retrieve
loading: {
finishedMsg: 'No more pages to load.',
img: 'http://i.imgur.com/6RMhx.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>
jQuery(函数(){
var$container=jQuery('ul.products');
$container.imagesLoaded(函数(){
$container.com({
itemSelector:'li.product',
列宽:295,
是的,
排水沟宽度:2
});
});
$container.infinites卷({
导航选择器:“#page nav woo”,//分页导航的选择器
下一个选择器:'.next',//下一个链接(到第2页)的选择器
itemSelector:'li.product',//将检索的所有项目的选择器
装载:{
FinishedMg:“没有更多页面要加载。”,
img:'http://i.imgur.com/6RMhx.gif'
}
},
//触发器作为回调
函数(新元素){
//在加载新项目时隐藏它们
var$newElems=jQuery(newElements).css({opacity:0});
//确保在添加到砌体布局之前加载图像
$newElems.imagesLoaded(函数(){
//显示元素现在他们准备好了
$newElems.animate({opacity:1});
$container.mashing('added',$newElems,true);
});
}
);
});
好的,我的问题的解决方案如下:
1.我安装了wp插件
2.对于添加的回调部分:
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.append( $newElems ).masonry( 'appended', $newElems, true );
});
3.性能:砌体
它就像一个符咒!谢谢大家 或者,您可以将脚本包装在闭包中:
(function($) {
// i can use $ instead of jQuery
} (jQuery));
或
你为什么不把所有的$都改成jQuery,看看会发生什么?你的代码看起来很好,你是否链接到Massy
jQuery插件?@AndyHolmes试过了,它破坏了一切(我指的是Massy)@Nunners是的,我正在尝试在卷轴完成工作后再次调用Massy,以便它重新排列所有的产品。。。但它不起作用:(+1代表jquery美元($)符号:)
(function(jQuery) {
// i can use jQuery instead of $
} ($));