From 0424fafa3a2a336ca25c0149151aefcdf310a5c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=84=E6=88=90=E6=96=87?= Date: Thu, 24 Oct 2013 15:57:39 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8DBUI.FormHelper.setFields(?= =?UTF-8?q?form,data);=E5=BD=93data=E4=B8=AD=E5=AD=98=E5=9C=A8=E5=A4=9A?= =?UTF-8?q?=E4=BD=99=E8=A1=A8=E5=8D=95=E9=A1=B9=E6=97=B6=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/util.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/common/util.js b/src/common/util.js index 1080276..220f863 100644 --- a/src/common/util.js +++ b/src/common/util.js @@ -583,6 +583,9 @@ define('bui/util',function(){ }, //设置字段的值 _setFieldValue : function(field,value){ + if (field == undefined) { + return; + } if(field.type === 'checkbox'){ if(field.value == value ||(BUI.isArray(value) && BUI.Array.indexOf(field.value,value) !== -1)) { $(field).attr('checked',true); -- Gitee From e591847e2ddbecade4ecfa4875367e81a96a36ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=84=E6=88=90=E6=96=87?= Date: Thu, 24 Oct 2013 16:40:28 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=A7=A3=E5=86=B3BUI.FormHelper.setFields(?= =?UTF-8?q?form,data);data=E4=B8=AD=E5=AD=98=E5=9C=A8=E9=9D=9Estring?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=80=BC=E6=97=B6=EF=BC=8C=E6=9C=AA=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E8=AE=BE=E7=BD=AEcheckbox=E5=92=8Cradio=E8=A1=A8?= =?UTF-8?q?=E5=8D=95=E5=80=BC=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=9A=20?= =?UTF-8?q?=E5=A6=82=EF=BC=8C=20=E5=BD=93data=3D{enable:=20=E2=80=98true?= =?UTF-8?q?=E2=80=99}=E6=97=B6=E5=8F=AF=E4=BB=A5=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=EF=BC=8C=E5=BD=93data=3D{enable:true}?= =?UTF-8?q?=E6=97=B6=E6=97=A0=E6=B3=95=E6=AD=A3=E7=A1=AE=E6=89=A7=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/util.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/common/util.js b/src/common/util.js index 220f863..ee833ac 100644 --- a/src/common/util.js +++ b/src/common/util.js @@ -587,13 +587,20 @@ define('bui/util',function(){ return; } if(field.type === 'checkbox'){ - if(field.value == value ||(BUI.isArray(value) && BUI.Array.indexOf(field.value,value) !== -1)) { + if(field.value == '' + value) { $(field).attr('checked',true); + } else if (BUI.isArray(value)) { + BUI.Array.each(value, function(v){ + if (field.value == '' + v ) { + $(field).attr('checked',true); + return false; + } + }); }else{ $(field).attr('checked',false); } }else if(field.type === 'radio'){ - if(field.value == value){ + if(field.value == '' + value){ $(field).attr('checked',true); }else{ $(field).attr('checked',false); -- Gitee From 0f6e2d3142031380e05d7b1453f9e3c51eb6888f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=84=E6=88=90=E6=96=87?= Date: Fri, 25 Oct 2013 11:09:20 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8DFormHelper.setField?= =?UTF-8?q?=E6=97=B6=EF=BC=8Cselect=E7=B1=BB=E5=9E=8B=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E6=9C=AA=E6=AD=A3=E7=A1=AE=E7=94=9F=E6=95=88=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/common.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/build/common.js b/build/common.js index 490f6b8..1003f71 100644 --- a/build/common.js +++ b/build/common.js @@ -599,14 +599,24 @@ define('bui/util',function(){ }, //设置字段的值 _setFieldValue : function(field,value){ + if (field == undefined) { + return; + } if(field.type === 'checkbox'){ - if(field.value == value ||(BUI.isArray(value) && BUI.Array.indexOf(field.value,value) !== -1)) { + if(field.value == '' + value) { $(field).attr('checked',true); + } else if (BUI.isArray(value)) { + BUI.Array.each(value, function(v){ + if (field.value == '' + v ) { + $(field).attr('checked',true); + return false; + } + }); }else{ $(field).attr('checked',false); } }else if(field.type === 'radio'){ - if(field.value == value){ + if(field.value == '' + value){ $(field).attr('checked',true); }else{ $(field).attr('checked',false); -- Gitee