/** * * 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 + '
' + data[i].title + '
'; ws = ws + '
' + data[i].description + '
'; } this.$traintext.empty().html(ws); this.$traininfo.removeClass('mui--hide').addClass('mui--show'); } else { this.$traininfo.removeClass('mui--show').addClass('mui--hide'); } } });