Created
October 6, 2011 01:13
-
-
Save wookiehangover/1266226 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var View = Backbone.View.extend({ | |
render: function() { | |
var _this = this; | |
// this.collection is passed in on instantiation | |
this.collection.deferred.done(function() { | |
var data = _this.collection.toJSON(); | |
// Lets just output the response into the DOM | |
$('pre').html( JSON.stringify( data, '', ' ' ) ); | |
}); | |
} | |
}); | |
// Initialize the Collection - this will call Collection.fetch() | |
// in the initializer and sets its deferred object to | |
// Collection.deferred() | |
var myCollection = new Collection(); | |
// Initialize the View, passing it the collection instance | |
var myView = new View({ | |
collection: myCollection | |
}); | |
// Call render immediately! | |
myView.render(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment