Skip to content

Instantly share code, notes, and snippets.

@rmcvey
Last active August 29, 2015 14:18
Show Gist options
  • Save rmcvey/6124030be31339f57dea to your computer and use it in GitHub Desktop.
Save rmcvey/6124030be31339f57dea to your computer and use it in GitHub Desktop.
define(['Controller', 'jsx!app/reports/views', 'jsx!views/datavis', 'jsx!views/shared', 'models/Report', 'react'],
function(Controller, Views, DataVis, Shared, Report, React) {
var vent = Application.Events;
// these will all be added on top of the controller namespace
var routes = {
// base route (<controller>/)
'': function(){
var reportCollection = new Report.List();
vent.on('report:filter', function(filter){
// update the where clause on the Backbone.Collection fetch
// Backbone.Collection and Backbone.Model updates and fetches automatically trigger setState calls
reportCollection.set({ where: filter });
});
var reportList = new Views.ReportList({
collection: reportCollection
});
this.views = [reportList];
},
'detail/:id': function(id){
var reportModel = new Report.Detail(id);
var reportHeader = new Views.ReportHeader({
model: reportModel
});
var reportDetail = Views.ReportDetail({
model: reportModel
});
this.views = [reportHeader, reportDetail];
}
}
return Controller.extend({
'namespace': 'reports',
'routes': routes,
'init': function(initData) {}
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment