diff --git a/index.html b/index.html index 9fbfcfe24..a7b1bc719 100755 --- a/index.html +++ b/index.html @@ -17,6 +17,13 @@
+ +
diff --git a/src/demo.js b/src/demo.js index 0cf72e52c..51b05a008 100644 --- a/src/demo.js +++ b/src/demo.js @@ -333,6 +333,7 @@ require(['config/require-config'], function() { window.editor = editor; + editor.render(); }); }); diff --git a/src/trait_manager/view/TraitSelectView.js b/src/trait_manager/view/TraitSelectView.js index dfa4d84e2..557a6e8f5 100644 --- a/src/trait_manager/view/TraitSelectView.js +++ b/src/trait_manager/view/TraitSelectView.js @@ -16,33 +16,44 @@ define(['backbone','./TraitView'], * @private */ getInputEl: function() { - if(!this.$input){ + if(!this.$input){ var md = this.model; - var opts = md.get('options') || []; - this.input = ''; if(opts.length){ _.each(opts, function(el){ - var name, value, style; - var attrs = ''; - if(typeof el === 'string'){ - name = el; - value = el; - }else{ - name = el.name ? el.name : el.value; - value = el.value.replace(/"/g,'"'); - style = el.style ? el.style.replace(/"/g,'"') : ''; - attrs += style ? 'style="' + style + '"' : ''; - } + var name, value, style; + var attrs = ''; + if(typeof el === 'string'){ + name = el; + value = el; + }else{ + name = el.name ? el.name : el.value; + value = el.value.replace(/"/g,'"'); + style = el.style ? el.style.replace(/"/g,'"') : ''; + attrs += style ? 'style="' + style + '"' : ''; + } this.input += ''; }, this); } this.input += ''; this.$input = $(this.input); - // TODO check also model attributes in case of changeProp + + var target = this.target; + var name = md.get('name'); var val = md.get('value'); + + if (md.get('changeProp')) { + val = val || target.get(name); + } else { + var attrs = target.get('attributes'); + val = attrs[name]; + } + if(val) this.$input.val(val); - } + } + return this.$input.get(0); },