Permalink
Browse files

fix: 单选、下拉、多选getShowValue获取不到值

  • Loading branch information...
LiuYueKai committed Apr 7, 2017
1 parent 0df9705 commit 860f4c151d3ed535c710203b199955daa0142754
Showing with 22 additions and 20 deletions.
  1. +10 −0 src/keroa-checkbox.js
  2. +4 −19 src/keroa-combo.js
  3. +8 −1 src/keroa-radio.js
View
@@ -233,6 +233,7 @@ var CheckboxAdapter = u.BaseAdapter.extend({
if (this.isGroup) {
if (this.datasource) {
+ this.showValue = '';
this.trueValue = val;
if (this.options.hasOther) {
var otherVal = '';
@@ -252,6 +253,11 @@ var CheckboxAdapter = u.BaseAdapter.extend({
if (self.options.hasOther) {
otherVal = otherVal.replace(inputValue + ',', '');
}
+ var nameSpan = ele.querySelector('[data-role=name]');
+ var showValue = $(nameSpan).text();
+ if (showValue) {
+ self.showValue += showValue + ',';
+ }
}
}
})
@@ -264,7 +270,11 @@ var CheckboxAdapter = u.BaseAdapter.extend({
if (otherVal) {
self.otherInput.oldValue = otherVal;
self.otherInput.value = otherVal;
+ self.showValue += otherVal + ',';
self.otherInput.removeAttribute('disabled');
+ self.otherComp._inputElement.checked = true;
+ self.otherComp._updateClasses();
+
}
}
}
View
@@ -63,39 +63,24 @@ var ComboboxAdapter = u.BaseAdapter.extend({
}
- ////TODO 后续支持多选
- //if (this.mutil) {
- // //$(this.comboEle).on("mutilSelect", function (event, value) {
- // // self.setValue(value)
- // //})
- //}
+
this.comp.on('select', function(event) {
- // self.slice = true;
- // if(self.dataModel)
- // self.dataModel.setValue(self.field, event.value);
- // self.slice = false;
self.setValue(event.value);
self.setShowValue(event.name);
});
- //if(this.dataModel){
- // this.dataModel.ref(this.field).subscribe(function(value) {
- // self.modelValueChange(value)
- // })
- //}
+
},
modelValueChange: function(value) {
if (this.slice) return;
//this.trueValue = value;
if (value === null || typeof value == "undefined")
value = "";
this.comp.setValue(value);
- // this.trueValue = this.formater ? this.formater.format(value) : value;
- // this.element.trueValue = this.trueValue;
+ if (this.mutil)
+ this.showValue = this.comp.name;
//下面两句会在校验中用到
this.trueValue = this.formater ? this.formater.format(value) : value;
this.element.trueValue = this.trueValue;
- // this.showValue = this.masker ? this.masker.format(this.trueValue).value : this.trueValue;
- // this.setShowValue(this.showValue);
},
//getValue: function () {
View
@@ -194,9 +194,10 @@ var RadioAdapter = u.BaseAdapter.extend({
modelValueChange: function(value) {
if (this.slice) return;
- var fetch = false;
+ var fetch = false,self = this;
if (this.dynamic) {
if (this.datasource) {
+ this.showValue = '';
this.trueValue = value;
this.element.querySelectorAll('.u-radio').forEach(function(ele) {
var comp = ele['u.Radio'];
@@ -206,6 +207,11 @@ var RadioAdapter = u.BaseAdapter.extend({
fetch = true;
addClass(comp.element, 'is-checked')
comp._btnElement.click();
+ var nameSpan = ele.querySelector('.u-radio-label');
+ var showValue = $(nameSpan).text();
+ if (showValue) {
+ self.showValue = showValue;
+ }
} else {
removeClass(comp.element, 'is-checked')
}
@@ -222,6 +228,7 @@ var RadioAdapter = u.BaseAdapter.extend({
}
}
if (this.options.hasOther && !fetch && value) {
+ this.showValue = value;
if (!this.enable) {
this.lastRadio.removeAttribute('disabled');
}

0 comments on commit 860f4c1

Please sign in to comment.