Browse Source

Setup a listener on properties

pull/487/head
Artur Arseniev 9 years ago
parent
commit
2850554b7c
  1. 60
      src/style_manager/view/PropertiesView.js

60
src/style_manager/view/PropertiesView.js

@ -17,33 +17,49 @@ module.exports = Backbone.View.extend({
this.onChange = o.onChange; this.onChange = o.onChange;
this.onInputRender = o.onInputRender || {}; this.onInputRender = o.onInputRender || {};
this.customValue = o.customValue || {}; this.customValue = o.customValue || {};
const coll = this.collection;
this.listenTo(coll, 'add', this.addTo);
this.listenTo(coll, 'reset', this.render);
}, },
render() {
var fragment = document.createDocumentFragment(); addTo(model) {
this.add(model);
this.collection.each((model) => { },
var view = new model.typeView({
model,
name: model.get('name'), add(model, frag) {
id: this.pfx + model.get('property'), var view = new model.typeView({
target: this.target, model,
propTarget: this.propTarget, name: model.get('name'),
onChange: this.onChange, id: this.pfx + model.get('property'),
onInputRender: this.onInputRender, target: this.target,
config: this.config, propTarget: this.propTarget,
}); onChange: this.onChange,
onInputRender: this.onInputRender,
if(model.get('type') != 'composite'){ config: this.config,
view.customValue = this.customValue;
}
view.render();
fragment.appendChild(view.el);
}); });
if (model.get('type') != 'composite') {
view.customValue = this.customValue;
}
view.render();
const el = view.el;
if (frag) {
frag.appendChild(el);
} else {
this.el.appendChild(el);
}
},
render() {
const fragment = document.createDocumentFragment();
this.collection.each(model => this.add(model, fragment));
this.$el.append(fragment); this.$el.append(fragment);
this.$el.attr('class', this.pfx + 'properties'); this.$el.attr('class', `${this.pfx}properties`);
return this; return this;
} }
}); });

Loading…
Cancel
Save