7

我正在使用同位素来构建一个平滑的网格画廊。目前我在附加功能方面遇到问题:http: //isotope.metafizzy.co/docs/methods.html#appended

如果我这样调用附加

$('#loadMore').click(function(){
    val='<div class="content-box masonry-brick img11"><a href="#"><img src="images/1.jpg" style="width: 290px; height: 163.36666666666667px; "><div class="portfolio-more"><div class="portfolio-icon"></div></div></a><div class="content-box-content"><h3 class="post-info">Lifestyle / People</h3><h2>Street Life</h2></div></div>';

    var $container = $('#grid-gallery');
    $container.isotope( 'appended', val)

    return false;
  }); 

然后同位素吐出以下错误消息:

[content] has no method 'filter'

如果我将定位添加到 div,那么它工作正常,除了新元素加载到该位置并保持固定。

4

1 回答 1

5

改变:

$container.isotope( 'appended', val);

$container.isotope( 'append', $(val) );

或者如果你想让它更干净,你可以这样做......

$('#loadMore').click(function(){

    val= $('<div class="content-box masonry-brick img11"><a href="#"><img src="images/1.jpg" style="width: 290px; height: 163.36666666666667px; "><div class="portfolio-more"><div class="portfolio-icon"></div></div></a><div class="content-box-content"><h3 class="post-info">Lifestyle / People</h3><h2>Street Life</h2></div></div>');

    var $container = $('#grid-gallery');
    $container.isotope( 'insert', val );

    return false;
}); 
于 2012-04-30T14:22:48.557 回答