#714

A simple playground for learning backbone.js without having to install or configure anything yourself.

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>

JavaScript

var Model = Backbone.Model.extend({
    set: function(){
        console.log(this.collection);
    }
});

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

var myModel = new Model();
var myCollection = new Collection();

myCollection.add( myModel ); // this.collection == undefined

myModel.set(); // this.collection = myCollection