Browse Source

Fix trait select view

pull/36/head
Artur Arseniev 10 years ago
parent
commit
1fb4f68cef
  1. 2
      src/trait_manager/model/TraitFactory.js
  2. 6
      src/trait_manager/view/TraitSelectView.js
  3. 1
      src/trait_manager/view/TraitView.js

2
src/trait_manager/model/TraitFactory.js

@ -42,7 +42,7 @@ define(['backbone'],
switch (prop) { switch (prop) {
case 'target': case 'target':
obj.options = [ obj.options = [
{value: '_self', name: 'This window'}, {value: '', name: 'This window'},
{value: '_blank', name: 'New window'} {value: '_blank', name: 'New window'}
]; ];
break; break;

6
src/trait_manager/view/TraitSelectView.js

@ -18,7 +18,8 @@ define(['backbone','./TraitView'],
*/ */
getInputEl: function() { getInputEl: function() {
if(!this.$input){ if(!this.$input){
var opts = this.model.get('options') || []; var md = this.model;
var opts = md.get('options') || [];
this.input = '<select>'; this.input = '<select>';
if(opts.length){ if(opts.length){
_.each(opts, function(el){ _.each(opts, function(el){
@ -38,6 +39,9 @@ define(['backbone','./TraitView'],
} }
this.input += '</select>'; this.input += '</select>';
this.$input = $(this.input); this.$input = $(this.input);
var val = md.get('value');
if(val)
this.$input.val(val);
} }
return this.$input.get(0); return this.$input.get(0);
}, },

1
src/trait_manager/view/TraitView.js

@ -18,6 +18,7 @@ define(['backbone'], function (Backbone) {
this.model.off('change:value', this.onValueChange); this.model.off('change:value', this.onValueChange);
this.listenTo(this.model, 'change:value', this.onValueChange); this.listenTo(this.model, 'change:value', this.onValueChange);
this.tmpl = '<div class="' + this.fieldClass +'"><div class="' + this.inputhClass +'"></div></div>'; this.tmpl = '<div class="' + this.fieldClass +'"><div class="' + this.inputhClass +'"></div></div>';
console.log(this.model.attributes);
}, },
/** /**

Loading…
Cancel
Save