#763

Simple test case for Backbone issues

by wookiehangover

HTML

<script src="http://documentcloud.github.com/underscore/underscore.js"></script>
<script src="http://documentcloud.github.com/backbone/backbone.js"></script>
<script src="https://getfirebug.com/firebug-lite.js"></script>
<pre id="foo">
    
</pre>

JavaScript

var data = [{ foo: 'bar' }, { foo: 'biz' }];

var Person = Backbone.Model.extend({});

var People = Backbone.Collection.extend({
    model: Person
});

var PeopleView = Backbone.View.extend({
    el: $('#foo'),
    
    initialize: function(){
        this.collection = new People( data );
        this.render();
    },
    
    render: function(){
        
        this.el.html( JSON.stringify( this.collection.toJSON(), '', '  ' ) );
    }
});

new PeopleView();