Knockout validation on my dropdown don't work

后端 未结 3 709
粉色の甜心
粉色の甜心 2021-01-07 01:26

I work on a asp.net mvc project with the durandal template + breeze.

I would like to define validation logic on my view for adding/editing operations.

So far

3条回答
  •  孤城傲影
    2021-01-07 01:41

    Finally I get it working by adding an element with empty id in my categories list:

    var categories = [
        { id: '', description: '--Choose--' },
        { id: 1, description: 'Non classé' },
        { id: 2, description: 'Non nucléaire' },
        { id: 3, description: 'Classe II irradié' },
        { id: 4, description: 'Classe III' }];
    

    I don't know why but simply adding optionsCaption: '--Choose--' don't work for the validation. I mean this element is displayed in my dropdown but the validation process don't consider it as a validation error.

    I explicitely had to add an element to my list. Then when this element is selected in my dropdown it is marked as red.

提交回复
热议问题