Issues with isotope appending

天大地大妈咪最大 提交于 2019-12-22 05:06:07

问题


I am using isotope to build a smooth grid gallery. Currently I am having issues with the append feature: http://isotope.metafizzy.co/docs/methods.html#appended

If I call the append like this

$('#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;
  }); 

Then isotopes spits out the following error msg:

[content] has no method 'filter'

If I add positioning to the div, then it works fine, except the new element is loaded to that position and remains fixed.


回答1:


Change:

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

To

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

Or you could do this if you want it cleaner....

$('#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;
}); 


来源:https://stackoverflow.com/questions/10034213/issues-with-isotope-appending

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!