I have a ListRoute that can be used standalone or overridden with a filter method.
Currently the overriding route accesses a global variable. I'm trying to get rid of globals but don't see a way to pass the context along to the function.
How can I pass the context along (in this case the 'currentUser') without globals. Or how should I rewrite this.
Why is 'this' in the extending function the window? I was hoping I'd be able to at least call this.modelFor() to access the necessary information.
Encompass.WorkspacesListRoute = Ember.Route.extend({
controllerName: 'workspaces.list',
templateName: 'workspaces/list',
filter: function(workspace) {
return true; //return everything by default, extenders will override this
},
model: function() {
var store = this.get('store');
return store.filter('workspace', this.get('filter'));
},
});
Encompass.WorkspacesMineRoute = Encompass.WorkspacesListRoute.extend({
filter: function(workspace) {
//at this point 'this' is the window (why not the route?)
return (Encompass.get('currentUser') === workspace.get('owner'));
}
});