Skip to content

Instantly share code, notes, and snippets.

@mattd
Created December 31, 2012 03:08
Show Gist options
  • Save mattd/4417128 to your computer and use it in GitHub Desktop.
Save mattd/4417128 to your computer and use it in GitHub Desktop.
define([
'marionette',
'views/layouts/groups',
'views/group/collection',
'views/learner/collection',
'collections/api/group',
'collections/api/learner'
], function (
Marionette,
GroupsLayout,
GroupCollectionView,
LearnerCollectionView,
GroupCollection,
LearnerCollection
) {
//"use strict";
return Marionette.Controller.extend({
initialize: function (options) {
this.region = options.region;
this.layout = new GroupsLayout();
},
showGroups: function (selectedGroupId) {
// TODO: Use selectedGroupId to select group.
var collection = new GroupCollection();
this.region.show(this.layout);
this.layout.groups.show(
new GroupCollectionView({
collection: collection
})
);
collection.fetch();
},
showLearners: function (groupId) {
var collection = new LearnerCollection({groupId: groupId});
// Handle direct linking from another hash.
if (this.layout.isClosed) {
this.layout.render();
}
// Handle fresh page load.
if (!this.layout.groups.currentView) {
this.showGroups(groupId);
}
this.layout.learners.show(
new LearnerCollectionView({
collection: collection
})
);
collection.fetch();
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment