Knockout validation on my dropdown don't work

后端 未结 3 1528
伪装坚强ぢ
伪装坚强ぢ 2021-01-07 01:06

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:32

    Just stumbled into this one as well and after some trial and error I found the following:

    The validation breaks down because the optionsCaption uses undefined as a value.

    Your model apparently uses '' (in my case it was null) Since null != undefined it somehow all breaks down.

    Knowing this, there are two solutions:

    1. on the Model set the value to undefined (in your example transport.category(undefined)) and make use of the optionsCaption like you're used to
    2. add a custom empty selectItem yourself and skip optionsCaption (the solution you used)

提交回复
热议问题