我想一个CSS类添加到select
在我看来元素,我的观点模型我已经使用淘汰赛验证扩展属性:
self.selectedRootCause = ko.observable().extend({
required: true
});
然后,我的select
是像这样:
<form data-bind="submit: closeComplaint" method="post">
<select data-bind="options: rootCauses,
optionsText: 'RootCauseText',
value: selectedRootCause,
optionsCaption: 'Choose..',
validationOptions: { errorElementClass:
'input-validation-error' }">
</select>
<input type="submit" value="Close Complaint" />
</form>
我closeComplaint
功能看起来像这样:
self.closeComplaint = function () {
if (self.errors().length == 0) {
$.ajax({
url: '@Url.Action("CloseComplaint")',
data: new DetailsComplaintAdmin(self.currentComplaint(),
self.selectedRootCause().RootCauseId
),
success: function (data) {
console.log(data);
}
});
}
}
刚刚完成,这是我的self.errors()
函数:
self.errors = ko.validation.group(self);
问题是类input-validation-error
不会出现被添加到我的select
输入时,我提出我的形式? 有任何想法吗?