Reputation: 61
I'm writing a small application using Backbone which is basically just a calculator with two pages. The first page shows some text inputs, and the second page shows the result plus a few sliders for fine tuning.
I've thought about using the Backbone router, but the second page should not be directly accessible by URL without entering the necessary values on the first page. The alternative of having the first view unload and remove itself from the DOM and then instantiate the result view seems kind of messy to me.
How would you design an application like this?
Upvotes: 3
Views: 707
Reputation: 110892
Keep it simple, when you dont wanna access the second view by an url you dont need a router. Just start your first view and change it with your second view when the user has entered the values.
Edit:
Lets say you have to views both with a render method where you can pass the div where the view is rendered in:
var View1 = Backbone.View.extend({
render: function(parent){
$(parent).empty().append(this.el);
}
ready: function(){
view2.render($('#mainPanel'));
}
})
var View2 = Backbone.View.extend({
render: function(parent){
$(parent).empty().append(this.el);
}
})
var view1 = new View1().render($('#mainPanel'));
var view2 = new View2()
Upvotes: 2