0

我正在尝试在同位素中附加内容,它可以工作,但是新内容位于已经存在的项目下而不是在它们之后。

这是我的 JQuery 代码:

  $('#og-grid').isotope({
    itemSelector : 'li'
  });

  $('#sort-by a').click(function(){
    var selector = $(this).attr('data-filter');
    $('#og-grid').isotope({ filter: selector });
    $('#og-grid').isotope( 'reLayout' );
    return false;
  });

  $('a#plus_projet').click(function(){
    var appendContent = $('.portfolio_projects_hide ul').html();
    $('.portfolio_projects ul').append(appendContent).isotope('appended', appendContent);
    $('#og-grid').isotope( 'reLayout' );
    return false;
  });
4

1 回答 1

0

Isotope 期望 jQuery 集合作为第二个参数。

尽管内容已正确更新,但在附加到容器时使用 jQuery 集合也会产生影响。

Demo Fiddle

尝试:

$('a#plus_projet').click(function(){
    var appendContent  = $('.portfolio_projects_hide ul').html();

    // Use this variable to append
    var $appendContent = $(appendContent);

    $('.portfolio_projects ul').append($appendContent).isotope('appended', $appendContent);

    // Not necessary when appending items...
    $('#og-grid').isotope('reLayout');
    return false;
});
于 2013-09-13T01:45:54.040 回答