jQuery的砌体追加项目问题 [英] Jquery Masonry append item issues

查看:178
本文介绍了jQuery的砌体追加项目问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个骨干获取视图的方法,做这样的:

I have a backbone fetch view method that does this:

var ResultsView = Backbone.View.extend({
  template : _.template($("#result_template").html()),
  render : function() {
    this.collection.each(function(result) {
      var $output = $(this.template(result.toJSON()));
      var $container = $('#result_content');
      $container.append($output)
      $container.masonry('appended', $output);
    }, this);
    return this;
  }
});

我所试图做的是对我的结果集合中的每个项目....它添加到我的#result_content格,以同样的方式作为可以在这里看到:的 http://masonry.desandro.com/demos/adding-items.html

这里的问题是,布局没有填充(它只是在此刻单列我在这一切像这样的结尾呼吁重装:

The issue here is that the layout is not filled (it's just a single column at the moment. I have to call reload at the end of all of this like so:

$container.masonry('reload')

这是不是我想要的。我想从自上而下追加。

Which is not what I want. I want to append from top down.

推荐答案

更改该行 $容器prePEND($输出).masonry('重装'); 然后删除后续行 $ container.masonry('附加',$输出); ,也不要叫刷新末

Change that line to $container.prepend($output).masonry('reload'); then remove the subsequent line $container.masonry('appended', $output); and also don't call "reload" at the end.

这篇关于jQuery的砌体追加项目问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆