I want to use BackboneJS for single page sites. The structure I am thinking of using is have a div#pageWrapper
for loading views into
# a simple example view
class View1 extends Backbone.View
render: ->
@$el.html @template()
class AppRouter extends Backbone.Router
routes:
"": "home"
"view1": "view1"
"view2": "view2"
home: ->
# init, render, attach to body. repeat for other controller actions
view = new HomeView()
view.render()
$("#pageWrapper").html view.el
Is the the usual way of doing this? Or is there some kind of design pattern alreay available? I havent handled the clean up, do I need it? Or is it a side effect of simply replacing the page wrappers' html?