Browse Source

Fix image component render

pull/36/head
Artur Arseniev 10 years ago
parent
commit
47e69a1c3b
  1. 3
      src/dom_components/model/Components.js
  2. 7
      src/dom_components/view/ComponentImageView.js

3
src/dom_components/model/Components.js

@ -61,12 +61,13 @@ define([ 'backbone', 'require'],
if(!_.isEmpty(style) && this.editor){ if(!_.isEmpty(style) && this.editor){
var cssC = this.editor.get('CssComposer'); var cssC = this.editor.get('CssComposer');
var newClass = this.editor.get('ClassManager').addClass(model.cid); var newClass = this.editor.get('ClassManager').addClass(model.cid);
model.set({attributes: {}, style:{}}); model.set({style:{}});
model.get('classes').add(newClass); model.get('classes').add(newClass);
var rule = cssC.newRule(newClass); var rule = cssC.newRule(newClass);
cssC.addRule(rule); cssC.addRule(rule);
rule.set('style', style); rule.set('style', style);
} }
console.log('After component add');
}, },
}); });

7
src/dom_components/view/ComponentImageView.js

@ -16,9 +16,6 @@ define(['backbone', './ComponentView'],
var compCls = this.config.imageCompClass || ''; var compCls = this.config.imageCompClass || '';
this.classEmpty = this.pfx + 'image-placeholder' + (compCls ? ' ' + compCls : ''); this.classEmpty = this.pfx + 'image-placeholder' + (compCls ? ' ' + compCls : '');
if(!this.model.get('src'))
this.$el.attr('class', this.classEmpty);
if(this.config.modal) if(this.config.modal)
this.modal = this.config.modal; this.modal = this.config.modal;
@ -56,6 +53,10 @@ define(['backbone', './ComponentView'],
render: function() { render: function() {
this.updateAttributes(); this.updateAttributes();
this.updateClasses(); this.updateClasses();
if(!this.model.get('src'))
this.$el.attr('class', this.classEmpty);
return this; return this;
}, },
}); });

Loading…
Cancel
Save