Commit 9e2131d6 authored by Renfred Harper's avatar Renfred Harper

Add backbone rendering views

parent 27a6e428
......@@ -3,6 +3,10 @@ var advisor = advisor || {};
advisor.Program = Backbone.RelationalModel.extend({
urlRoot: '/api/programs',
initialize: function() {
this.fetch();
},
relations: [{
type: Backbone.HasMany,
key: 'requirements',
......
var advisor = advisor || {};
advisor.CourseView = Backbone.View.extend({
tagName: 'div',
template: _.template( $('#course-template').html() ),
events: {
},
initialize: function() {
this.listenTo(this.model, 'change', this.render);
},
// Re-renders the titles of the todo item.
render: function() {
$('body').append( this.template( this.model.toJSON() ) );
return this;
},
});
var advisor = advisor || {};
advisor.ProgramCollectionView = Backbone.View.extend({
el: '#programs',
initialize: function() {
this.addAll();
},
addOne: function(program) {
var view = new advisor.ProgramView({ model: program });
this.$el.append( view.render().el );
},
// Add all items in the **Todos** collection at once.
addAll: function() {
this.$el.html('');
advisor.Programs.each(this.addOne, this);
}
});
var advisor = advisor || {};
advisor.ProgramView = Backbone.View.extend({
template: _.template( $('#program-template').html() ),
initialize: function() {
this.listenTo(this.model, 'change', this.render);
},
render: function() {
this.$el.html( this.template( this.model.toJSON() ) );
return this;
},
});
......@@ -46,8 +46,14 @@
{% block javascript %}
{{ block.super }}
<script src="/static/js/grids.js"></script>
<script src="/static/js/advisor/models/requirement.js"></script>
<script src="/static/js/advisor/models/program.js"></script>
<script src="/static/js/advisor/models/requirement.js"></script>
<script src="/static/js/advisor/models/course.js"></script>
<script src="/static/js/advisor/collections/programs.js"></script>
<script src="/static/js/advisor/collections/requirements.js"></script>
<script src="/static/js/advisor/collections/courses.js"></script>
<script src="/static/js/advisor/views/course-view.js"></script>
<script src="/static/js/advisor/views/programView.js"></script>
<script src="/static/js/advisor/views/programCollectionView.js"></script>
<script src="/static/js/advisor/app.js"></script>
{% endblock %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment