selectタグへの送信の値がknockoutjsを使用して「グローバル」以外の場合、部門選択タグを有効にしようとしています。しかし何らかの理由で部門選択タグが初期の有効/無効状態に固執しています。動的有効/無効は、他の要素に対して有効である。他の選択タグを動的に有効/無効にする
<select data-bind="options: recipientSelector, optionsText: 'name',value: selectedRecipient">
無効にする必要があるselectタグの有効/無効状態を決定textareaの
選択/
<select data-bind="options: department_name"></select>
Javascrptを有効にViewModel
var SendMessageModel = function() {
var self = this;
this.to = ko.observableArray();
this.to_all = ko.observable();
this.title = ko.observable();
this.message = ko.observable();
this.recipientSelector = [
{ recipient: "global", name: "To All" },
{ recipient: "custom", name: "Custom" }
];
this.selectedRecipient = ko.observable();
this.department_name = ['CSE', 'ECE', 'EE'];
self.disableSelects = ko.pureComputed(function() {
return self.selectedRecipient().recipient == "global";
});
};
ko.applyBindings(new SendMessageModel());
Screenshot "Custom" option enables "Department" select element
いいえ。これはまだ動作しません。問題は選択タグのみであり、他のフィールドはすべて正常に動作しているようです。 – Arka
私のために、それは働いています:https://jsfiddle.net/u2tL72dq/ – user3297291