1
0
mirror of https://github.com/danbee/tube-status-server synced 2025-03-04 08:39:12 +00:00
tube-status-server/javascripts/views/line_list.js
2013-01-25 17:54:45 +00:00

37 lines
761 B
JavaScript

define(['backbone',
'text',
'mustache',
'models/line',
'collections/lines',
'text!templates/line.mustache'],
function(Backbone,
Text,
Mustache,
Line,
LineCollection,
lineTemplate) {
var LineList = Backbone.View.extend({
initialize: function() {
var view = this;
this.collection.on("reset", function() {
view.render();
});
},
render: function() {
var html = "";
this.collection.models.forEach(function(model) {
html += Mustache.render(lineTemplate, model.toJSON());
});
// render the HTML and refresh jQuery Mobile.
this.$el.html(html);
},
el: '#line-list'
});
return LineList;
});