Reddit Image Gallery

backbone

by octatone

HTML

<script src="http://documentcloud.github.com/underscore/underscore-min.js"></script>
<script src="http://documentcloud.github.com/backbone/backbone-min.js"></script>
<script type='text/template' id='image_template'>
    <div class='image-container'>
        <img src='<%= img_src %>'/>
    </div>
</script>

JavaScript

/* models and collections */
var Image = Backbone.Model.extend({
    defaults: {
        id: undefined,
        title: undefined,
        src: undefined
    },
    initialize: function(){
        console.log('img '+this.id+' created');
    }
});

var Gallery = Backbone.Collection.extend({
    model: Image
});

/* views */