comindware.core.ui
Version:
Comindware Core UI provides the basic components like editors, lists, dropdowns, popups that we so desperately need while creating Marionette-based single-page applications.
43 lines (35 loc) • 944 B
text/typescript
import LayoutBehavior from '../behaviors/LayoutBehavior';
type optionsT = {
text: string,
model?: Backbone.Model,
key?: string
};
export default Marionette.View.extend({
initialize(options: optionsT) {
this.text = options.text || '';
this.key = options.key;
if (this.model && this.key) {
this.listenTo(this.model, `change:${this.key}`, (model, newValue) => this.$el.text(newValue));
}
},
className() {
return this.options.class ? this.options.class : '';
},
template: _.noop,
behaviors: {
LayoutBehavior: {
behaviorClass: LayoutBehavior
}
},
onRender() {
if (this.model && this.key) {
this.el.innerHTML = this.model.get(this.key);
} else {
this.el.innerHTML = this.text;
}
this.__updateState();
},
update() {
this.__updateState();
}
});