Lesson overview simplification moving template to separate file.
This commit is contained in:
@ -109,8 +109,7 @@ define(['jquery',
|
||||
this.listenTo(this,'hints:show',this.onShowHints);
|
||||
|
||||
this.helpControlsView.render();
|
||||
this.lessonOverviewModel.fetch();
|
||||
|
||||
this.lessonOverview.hideLessonOverview();
|
||||
this.titleView.render(this.lessonInfoModel.get('lessonTitle'));
|
||||
};
|
||||
|
||||
@ -186,11 +185,10 @@ define(['jquery',
|
||||
|
||||
this.showHints = function() {
|
||||
this.lessonHintView.render();
|
||||
//this.lessonHintView.
|
||||
};
|
||||
|
||||
this.showLessonOverview = function() {
|
||||
this.lessonOverview.render();
|
||||
this.lessonOverviewModel.fetch().then(this.lessonOverview.render());
|
||||
};
|
||||
|
||||
this.hideShowAttack = function (options) { // will likely expand this to encompass
|
||||
|
@ -1,8 +0,0 @@
|
||||
define([
|
||||
'backbone'],
|
||||
function(
|
||||
Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
});
|
||||
});
|
||||
|
@ -0,0 +1,5 @@
|
||||
<div>
|
||||
<% _.each(assignments, function(assignment) { %>
|
||||
<li><strong><a href="#" data-id=<%= assignment.assignment.path %>><%= assignment.assignment.name %></a></strong> (<%= assignment.solved %>)</li>
|
||||
<% }) %>
|
||||
</div>
|
@ -1,24 +0,0 @@
|
||||
define([
|
||||
'backbone'],
|
||||
function(
|
||||
Backbone) {
|
||||
return Backbone.View.extend({
|
||||
tagName: 'li',
|
||||
template: _.template($('#assignmentTemplate').html() ),
|
||||
|
||||
events: {
|
||||
"click a": "clicked"
|
||||
},
|
||||
|
||||
clicked: function(e){
|
||||
e.preventDefault();
|
||||
var id = $(e.currentTarget).data("id");
|
||||
Backbone.trigger('assignment:navTo',{'assignment': id});
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.html(this.template(this.model.toJSON()));
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
@ -2,26 +2,35 @@ define(['jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'goatApp/model/LessonOverviewModel',
|
||||
'goatApp/view/AssignmentOverview'],
|
||||
'text!templates/lesson_overview.html'],
|
||||
function($,
|
||||
_,
|
||||
Backbone,
|
||||
LessonOverviewModel,
|
||||
AssignmentOverview) {
|
||||
LessonOverviewTemplate) {
|
||||
return Backbone.View.extend({
|
||||
template: LessonOverviewTemplate,
|
||||
el:'#lesson-overview',
|
||||
initialize: function (lessonOverviewModel) {
|
||||
this.model = lessonOverviewModel;
|
||||
this.listenTo(this.model, 'change add remove update', this.render);
|
||||
this.listenTo(this.model, 'change add remove update reset', this.render);
|
||||
this.hideLessonOverview();
|
||||
},
|
||||
|
||||
events: {
|
||||
"click a": "clickedAssignment"
|
||||
},
|
||||
|
||||
clickedAssignment: function(e){
|
||||
e.preventDefault();
|
||||
var id = $(e.currentTarget).data("id");
|
||||
Backbone.trigger('assignment:navTo',{'assignment': id});
|
||||
},
|
||||
|
||||
showAssignments: function() {
|
||||
this.$el.html('');
|
||||
this.model.each(function(assignment) {
|
||||
var assignmentView = new AssignmentOverview({ model: assignment });
|
||||
this.$el.append(assignmentView.render().el);
|
||||
}, this);
|
||||
var t = _.template(this.template);
|
||||
this.$el.html(t({"assignments" : this.model.toJSON()}));
|
||||
},
|
||||
|
||||
render: function() {
|
||||
|
@ -40,13 +40,6 @@
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script id="assignmentTemplate" type="text/template">
|
||||
<![CDATA[
|
||||
<!-- CDATA is necessary otherwise we get into trouble with the strict HTML5 validation (Thymeleaf) -->
|
||||
<strong><a href="#" data-id=<%= assignment.path %>><%= assignment.name %></a></strong> (<%= solved %>)
|
||||
<!-- ]]> -->
|
||||
</script>
|
||||
|
||||
<section id="container">
|
||||
<header id="header">
|
||||
<!--logo start-->
|
||||
|
Reference in New Issue
Block a user