Change event on select with knockout binding, how can I know if it is a real change?

前端 未结 11 1901
独厮守ぢ
独厮守ぢ 2021-01-30 08:05

I am building a permissions UI, I have a list of permissions with a select list next to each permission. The permissions are represented by an observable array of objects which

11条回答
  •  梦谈多话
    2021-01-30 08:29

    I had a similar problem and I just modified the event handler to check the type of the variable. The type is only set after the user selects a value, not when the page is first loaded.

    self.permissionChanged = function (l) {
        if (typeof l != 'undefined') {
            ...
        }
    }
    

    This seems to work for me.

提交回复
热议问题