可观察到的淘汰赛没有受到约束

Knockout observable not getting bound

我正在使用表单进行编辑 purposes.The 当表单获取 loaded.The 时,分类代码被填充 loaded.The 字段绑定到 HTML 中使用数据绑定 attribute.The 我面临的唯一问题是当数据发送到控制器时这个特定字段(分类法代码)为 NULL。

HTML 是

<div class="form-group">
    <label class="col-sm-2 control-label labelfont">Certification:</label>
    <div class="col-sm-6">
        <select class="form-control" id="certification" name="certification" data-bind="value:certification,options:certificationArray, optionsCaption: 'Select a Certification'">
        </select>
    </div>
</div>

<div class="form-group">
    <label class="col-sm-2 control-label labelfont">Specialization:</label>
    <div class="col-sm-6">
        <select class="form-control" id="specialization" name="specialization" data-bind="value:specialization,options:specializationArray, optionsCaption: 'Select a Specialization'"></select>
    </div>
</div>

<div class="form-group">
    <label class="col-sm-2 control-label labelfont">Taxonomy Code:</label>
    <div class="col-sm-6">
        <input type="text" class="form-control" placeholder="Taxonomy code" id="taxonomyCode" name="taxonomyCode" data-bind="textInput: taxonomyCode,valueUpdate: 'input'" disabled="disabled">
    </div>
</div>

JavaScript 是

var provider = function() {
    var self = this;

    if ((providerEditInfo.Certification == "M.D.") || (providerEditInfo.Certification == "M.B.B.S")) {
        specialities = ["Dermatology", "Hematology", "Neurology"];
    } else if ((providerEditInfo.Certification == "R.N.") || (providerEditInfo.Certification == "M.S.N.")) {
        specialities = ["Pediatric Nursing", "Critical Care Nursing", "Occupational Health Nursing"];
    }
    self.certificationArray = ko.observableArray(["M.B.B.S", "M.D.", "R.N.", "M.S.N."]);
    self.certification = ko.observable(providerEditInfo.Certification);
    self.specializationArray = ko.observableArray(specialities);
    self.specialization = ko.observable(providerEditInfo.Specialization);
    self.taxonomyCode = ko.observable(providerEditInfo.TaxonomyCode);
    self.certification.subscribe(function(val) {
        self.specializationArray([]);

        if (val == "M.D." || val == "M.B.B.S") {
            self.specializationArray(["Dermatology", "Hematology", "Neurology"])
        } else if (val == "R.N." || val == "M.S.N.") {
            self.specializationArray(["Pediatric Nursing", "Critical Care Nursing", "Occupational Health Nursing"])
        } else {
            self.specializationArray([]);
        }
    });
    self.specialization.subscribe(function(val) {
        self.taxonomyCode("");
        if (val == "Dermatology")
            self.taxonomyCode("207N00000X");
        else if (val == "Hematology")
            self.taxonomyCode("207RH0000X");
        else if (val == "Neurology")
            self.taxonomyCode("2084N0400X");
        else if (val == "Pediatric Nursing")
            self.taxonomyCode("363LP0200X");
        else if (val == "Critical Care Nursing")
            self.taxonomyCode("363LC0200X");
        else if (val == "Occupational Health Nursing")
            self.taxonomyCode("363LX0106X");
    });
};

$(document).ready(function() {
    ko.applyBindings(new provider());
});

我只添加了最少的 code.Could 有人请告诉我为什么分类字段是 null.Please 请参考所附图片。

大多数浏览器不提交禁用字段的值。如果您希望将值发送到服务器,您需要想出一种不同的方法来防止用户编辑该字段。