Knockout master detail not working with select

前端 未结 1 723
小蘑菇
小蘑菇 2021-01-16 17:19
here`see my fiddle

http://jsfiddle.net/kirannandedkar/JUChh/2/

When i click on name it doesnt load up select list and gives errror that fun

相关标签:
1条回答
  • 2021-01-16 17:38

    Modules observable array contains simple js objects without observables so when accessing its properties you don't need to put (). Remove it from data.Id in selectPerson function:

    selectPerson = function(p){
        selectedPerson(p);
         editModuleId(ko.utils.arrayFirst(modules(), function (data) {
                console.log("item module id " + p.ModuleId());
                return data.Id === p.ModuleId();
            }));
    };
    

    Here is working fiddle: http://jsfiddle.net/JUChh/3/

    I look at your code closer and found that editModuleId is redundant. You have needed property inside selectedPerson object - ModuleId and should bind value of dropdown to it.

    Here is refactored fiddle: http://jsfiddle.net/JUChh/18/

    0 讨论(0)
提交回复
热议问题