-
-
Save unicornrainbow/3893659 to your computer and use it in GitHub Desktop.
more than just backbone constructs
This file contains 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
AppView = Backbone.View.extend({ | |
initialize: function(){ | |
this.router = new AppRouter(); | |
this.collection = new MyCollection(); | |
this.someView = new SomeView(); | |
this.someView.render(); | |
Backbone.history.start(); | |
} | |
}); |
This file contains 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
function MyApp(){ | |
var router = new MyRouter(); | |
var myCollection = new MyCollection(); | |
var someView = new SomeView({collection: myCollection}); | |
this.start = function(initialModels){ | |
myCollection.reset(initialModels); | |
someView.render(); | |
Backbone.history.start(); | |
} | |
} | |
var someModels = [...]; | |
new MyApp().start(someModels); |
This file contains 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
// simple, object literal event thingy | |
var myThingy = _.extend({}, Backbone.Events); | |
// or a full object | |
function MyThingy(){ | |
_.extend(MyThingy.prototype, Backbone.Events); | |
// other stuff here | |
} | |
var myThingy = new myThingy(); | |
// use events! | |
myThingy.trigger("some:event"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment