Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. app.WallView = Backbone.View.extend({
  2.  
  3. el: '#wall',
  4.  
  5. initialize: function() {
  6.  
  7. this.collection = new app.ImageCollection();
  8. this.collection.fetch({reset: true});
  9. this.render();
  10.  
  11. this.listenTo( this.collection, 'reset', this.render );
  12. },
  13.  
  14. render: function() {
  15.  
  16. this.collection.each(function( item ) {
  17. this.renderImage( item );
  18. }, this );
  19.  
  20. var $container = $("#wall");
  21. $container.imagesLoaded( function() {
  22. $container.masonry({
  23. });
  24. });
  25.  
  26.  
  27. },
  28.  
  29. renderImage: function( item ) {
  30. var imageView = new app.ImageView({
  31. model: item
  32. });
  33. this.$el.append( imageView.render().el );
  34. }
  35. });
  36.  
  37. new app.WallView();
  38.  
  39. <div id="wall" class="images"></div>
  40.  
  41. <script type="text/template" id="image-template">
  42. <img src="<%= url %>"></img>
  43. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement