fsb_backbone/app/components/EventItemView.js
Martin Donnelly e1d9657e87 init
2021-03-12 07:55:43 +00:00

33 lines
869 B
JavaScript

const _ = require('underscore');
const Backbone = require('backbone');
const templates = require('./templates');
const EventItemView = Backbone.View.extend({
'tagName': 'div',
'className': 'itemRow mui-row',
'template': _.template('<div>Not set</div>'),
'initialize': function() {
if (templates.hasOwnProperty(this.model.get('type')))
this.template = templates[this.model.get('type')];
this.listenTo(this.model, 'change', this.onChange);
this.render();
},
'onChange': function() {
this.render();
},
'render': function() {
this.$el.html(this.template(this.model.toJSON()));
},
'updateVisibility': function() {
let visibleClass = '';
if (active !== null)
visibleClass = (active === true) ? 'active' : 'notActive' ;
this.model.set('visibleClass', visibleClass) ;
}
});
module.exports = EventItemView;