I'm struggling to make out collections, models, etc. in backbone.
Let's say an application consists of a sidebar, a Timeslider graph, and a column:

To provide some background, I previously implemented the columnChart class using the functional inheritance pattern:
namespace.columnChart = function() { var chart = {}; var width = 500; var height = 500; var data = []; chart.setState = function(state){ data = state.data; updateVis(); } function updateVis(){ ... render chart based on state ... } return chart; }
With a simple binding, I can call the setState method on the Chart column when, for example, it adds a new object from the sidebar. But as the model grows (and the state becomes more complex with variables such as year, currentSelection, chartType, etc.), which I would also like to reflect in the URL, I would like to use MVC and, in particular, Backbone .js.
- So how do I structure this in a backbone?
- Should I rewrite the columnChart class (and similar classes)?
- Is there an easy way to determine what has changed in a state and only set a new state using these parameters?
An example of snapping Sidebar, Timeslider, and Column charts together - using Backbone - would be greatly appreciated.
Thanks.
source share