【发布时间】:2016-10-21 17:50:43
【问题描述】:
我需要在文本框数据绑定中添加动态属性
<input class="form-control" type="text" data-bind="
attr:{
name:$data.FieldName,
req: !$data.Nullable,
placeholder:$data.DefValue,
disabled:$data.Editable != null && !$data.Editable == true,
required: $data.Nullable != null && !$data.Nullable,
'data-bv-notempty':$data['data-bv-notempty'],
'data-bv-notempty-message': $data['data-bv-notempty-message']
},
value: $root.selScreen.isEditMode() ? ActualData : ''
">
如果我在列表下面的数组中定义,那么它应该添加
'data-bv-notempty': $data['data-bv-notempty'],
'data-bv-notempty-message': $data['data-bv-notempty-message']
或
'data-bv-notempty':'true',
'data-bv-notempty-message': 'This field can not be empty'
明智的
'data-bv-regexp':'true',
'data-bv-regexp-regexp':''^\d*'',
'data-bv-regexp-message': 'This field can only consist of integer value'
我在数组中添加的任何东西都应该添加到这个
data-bind="attr:{
'data-bv-regexp':'true',
'data-bv-regexp-regexp':''^\d*'',
'data-bv-regexp-message': 'This field can only consist of integer value'
}"
不想使用 jQuery 或 Observable 对象
【问题讨论】:
标签: jquery knockout.js