[#88,view/grid,refactor][s]: switch DataGrid to use new state setup (and introduce new Model ObjectState for this purpose).

* Switched hiddenFields to be part of state object (only state on DataGrid at the moment).
This commit is contained in:
Rufus Pollock
2012-04-14 12:58:39 +01:00
parent 5eb075b14c
commit 670eb1e1de
5 changed files with 63 additions and 28 deletions

View File

@@ -108,12 +108,8 @@ my.DataExplorer = Backbone.View.extend({
})
}];
}
this.state = {
dataset: null,
queryState: this.model.queryState.toJSON(),
currentView: null
};
this._setupStateManagement();
this.state = {};
this._setupState();
// this must be called after pageViews are created
this.render();
@@ -237,15 +233,21 @@ my.DataExplorer = Backbone.View.extend({
}
},
_setupStateManagement: function() {
_setupState: function() {
var self = this;
this.state = {
dataset: null,
query: this.model.queryState.toJSON(),
currentView: null
};
this.model.queryState.bind('change', function() {
self.state.queryState = this.model.queryState.toJSON();
});
_.each(this.pageViews, function(pageView) {
if (pageView.view.state && pageView.view.state.bind) {
self.state['view-' + pageView.id] = pageView.view.state.toJSON();
pageView.view.state.bind('change', function() {
self.state['view-' + pageView.view.id] = pageView.view.state.toJSON();
self.state['view-' + pageView.id] = pageView.view.state.toJSON();
});
}
});