Created
March 11, 2016 15:33
-
-
Save julesbou/66133708c1d63949e562 to your computer and use it in GitHub Desktop.
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
var Router = Backbone.Router.extend({ | |
init: function() { | |
this.views = []; | |
}, | |
routes: { | |
'load/:index': 'loadView' | |
}, | |
instanciateView: function(index) { | |
var model = new Backbone.Model({ | |
index: parseInt(index, 10), | |
name: 'view' + index | |
}); | |
// just creating a view | |
return new View({ model: model }); | |
}, | |
loadView: function(index) { | |
var view = this.instanciateView(index); | |
// store view in an array to access it later | |
this.views.push(view); | |
// (tip) problem is in line below | |
$('#app').html(view.render().$el); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment