cookie view re-enabled

This commit is contained in:
Jason White
2015-08-13 21:46:13 -04:00
parent da5a63453b
commit 1351f0e6a2
6 changed files with 61 additions and 16 deletions

View File

@ -8,6 +8,7 @@ define(['jquery',
'goatApp/view/SolutionView',
'goatApp/view/LessonHintView',
'goatApp/view/HelpControlsView',
'goatApp/view/CookieView',
'goatApp/support/GoatUtils'
],
function($,
@ -20,6 +21,7 @@ define(['jquery',
SolutionView,
LessonHintView,
HelpControlsView,
CookieView,
GoatUtils
) {
'use strict'
@ -77,6 +79,7 @@ define(['jquery',
this.lessonHintView = new LessonHintView();
this.listenToOnce(this.lessonHintView,'hints:loaded',this.areHelpsReady);
//
this.cookieView = new CookieView();
this.hideShowHelps(null);
};

View File

@ -0,0 +1,13 @@
define(['jquery',
'underscore',
'backbone',
'goatApp/model/LessonCookieModel'],
function($,
_,
Backbone,
LessonCookieModel) {
return Backbone.Collection.extend({
url:'service/cookie.mvc',
model:LessonCookieModel
});
});

View File

@ -0,0 +1,9 @@
define(['jquery',
'underscore',
'backbone'],
function($,
_,
Backbone) {
return Backbone.Model.extend({
});
});

View File

@ -0,0 +1,33 @@
define(['jquery',
'underscore',
'backbone',
'goatApp/model/LessonCookieCollection'],
function($,
_,
Backbone,
LessonCookieCollection) {
return Backbone.View.extend({
el:'#cookies-view',
initialize: function() {
this.collection = new LessonCookieCollection();
this.listenTo(this.collection,'reset',this.render)
this.collection.fetch({reset:true});
},
render: function() {
this.$el.html('')
var cookieTable;
this.collection.each(function(model) {
cookieTable = $('<table>',{'class':'cookie-table table-striped table-nonfluid'});
_.each(model.keys(), function(attribute) {
var newRow = $('<tr>');
newRow.append($('<th>',{text:_.escape(attribute)}))
newRow.append($('<td>',{text:_.escape(model.get(attribute))}));
cookieTable.append(newRow);
});
});
this.$el.append(cookieTable);
}
});
});