Skip to content

Instantly share code, notes, and snippets.

@alexandernst
Created June 24, 2012 13:30
Show Gist options
  • Save alexandernst/2983237 to your computer and use it in GitHub Desktop.
Save alexandernst/2983237 to your computer and use it in GitHub Desktop.
Backbone Views creation
window.App = Backbone.Router.extend({
initialize: function(){
this.route(/^$/, 'mainPage');
}
mainPage: function(){
console.log("Showing main page...");
var content = $('#content');
content.empty();
var menuView = new MenuView();
content.append(headerMenuViews.render().el);
var mainContentView = new MainContentView({
model: someModel
});
content.append(mainContentView.render().el);
//You can also append the content of one or more views to a DIV
var specialPlaceOnPage = $("<div></div>").appendTo(content);
var fooView = new FooView();
specialPlaceOnPage.append(fooView.render().el);
var barView = new BarView();
specialPlaceOnPage.append(barView.render().el);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment