Question

I would like to append new views to my existing masonry list. Why does my view not append? Am I missing something?

Masonry.js

function:

render_masonry_append: function() {
             var self = this;
            _(this.collection_append.models).each(function(item) {
                var view = new Home_thumbnail_view({
                    model: item.attributes
                });
                //console.log(view);
                $mainListContainer.append(view.render()).masonry("appended", view.render());
            });
            console.log($mainListContainer);
        }

Thanks!

Était-ce utile?

La solution

Make sure view.render() returns this, and then change that line to:

$mainListContainer.append(view.render().el).masonry("appended", view.render().el);

I'm not sure what masonry() does, so I added view.render().el there too, but that's your call. Most likely you don't need to be render()ing the view twice, so maybe even better would be:

view.render();
$mainListContainer.append(view.el).masonry("appended", view.el);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top