|
|
|
@ -18,7 +18,7 @@ module.exports = require('./PropertyView').extend({ |
|
|
|
const prop = model.get('property'); |
|
|
|
const options = model.get('list') || model.get('options') || []; |
|
|
|
|
|
|
|
if (!this.$input) { |
|
|
|
if (!this.input) { |
|
|
|
if(options && options.length) { |
|
|
|
let inputStr = ''; |
|
|
|
|
|
|
|
@ -31,31 +31,33 @@ module.exports = require('./PropertyView').extend({ |
|
|
|
<div class="${ppfx}radio-item"> |
|
|
|
<input type="radio" class="${pfx}radio" id="${id}" name="${prop}" value="${el.value}"/> |
|
|
|
<label class="${cl || itemCls}" ${titleAttr} for="${id}">${cl ? '' : labelTxt}</label> |
|
|
|
</div>`; |
|
|
|
</div> |
|
|
|
`;
|
|
|
|
}); |
|
|
|
|
|
|
|
this.$inputEl = $(inputStr); |
|
|
|
this.input = this.$inputEl.get(0); |
|
|
|
this.$el.find(`#${pfx}input-holder`).html(this.$inputEl); |
|
|
|
this.$input = this.$inputEl.find(`input[name="${prop}"]`); |
|
|
|
const inputHld = this.el.querySelector(`#${pfx}input-holder`); |
|
|
|
inputHld.innerHTML = `<div>${inputStr}</div>`; |
|
|
|
this.input = inputHld.firstChild; |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
/* |
|
|
|
getInputValue() { |
|
|
|
return this.$input ? this.$el.find('input:checked').val() : ''; |
|
|
|
}, |
|
|
|
*/ |
|
|
|
getInputValue() { |
|
|
|
const input = this.getInputEl(); |
|
|
|
const inputIn = input ? input.querySelector('input:checked') : ''; |
|
|
|
return inputIn ? inputIn.value : ''; |
|
|
|
}, |
|
|
|
|
|
|
|
setValue(value) { |
|
|
|
const model = this.model; |
|
|
|
var v = model.get('value') || model.getDefaultValue(); |
|
|
|
|
|
|
|
if (value) { |
|
|
|
v = value; |
|
|
|
} |
|
|
|
|
|
|
|
if(this.$input) |
|
|
|
this.$input.filter(`[value="${v}"]`).prop('checked', true); |
|
|
|
let val = value || model.get('value') || model.getDefaultValue(); |
|
|
|
const input = this.getInputEl(); |
|
|
|
const inputIn = input ? input.querySelector(`[value="${val}"]`) : ''; |
|
|
|
inputIn && (inputIn.checked = true); |
|
|
|
}, |
|
|
|
|
|
|
|
}); |
|
|
|
|