silvrgit/app/js/modules/train.js

46 lines
1.0 KiB
JavaScript
Raw Normal View History

2016-10-05 14:09:12 +00:00
/**
*
* User: Martin Donnelly
* Date: 2016-10-03
* Time: 14:20
*
*/
var TrainModel = Backbone.Model.extend({});
var Train = Backbone.View.extend({
tagName: 'div',
initialize: function() {
_.bindAll(this, 'render');
this.model.bind('change', this.render);
this.$traininfo = $('#traininfo');
this.$traintext = $('#traintext');
},
render: function() {
console.log('Train:Render');
var ws ='';
var data = this.model.get('data');
console.log(this.model);
if (data.length > 0)
{
for (var i = 0; i < data.length; i++)
{
ws = ws + '<div class="mui-row"><div class="mui-col-md-12"><strong>' + data[i].title + '</strong></div></div>';
ws = ws + '<div class="mui-row"><div class="mui-col-md-12">' + data[i].description + '</div></div>';
}
this.$traintext.empty().html(ws);
this.$traininfo.removeClass('mui--hide').addClass('mui--show');
} else {
this.$traininfo.removeClass('mui--show').addClass('mui--hide');
}
}
});