![](/img/trans.png)
[英]KnockoutJS custom binding to get comma separated values from multi select
[英]Using custom knockoutjs select binding with standard select bindings as well
我正在嘗試將自定義的基因敲除結合與標准結合。 雖然我已經能夠找到相關的解決方案
ko.bindingHandlers.parentAreaComboBox = {
initialised: false,
init: function (element, valueAccessor, allBindingsAccessor, viewModel, context) {
viewModel.parentAreas.subscribe(function (newParentAreas) {
if (newParentAreas && newParentAreas.length > 0) {
if (ko.bindingHandlers.parentAreaComboBox.initialised) {
return;
}
ko.applyBindingsToNode(element, {
options: viewModel.parentAreas,
optionsCaption: 'Choose...',
optionsText: 'Label',
value: viewModel.selectedParentArea
});
$(element).chosen({});
ko.bindingHandlers.parentAreaComboBox.initialised = true;
}
});
}
};
但我無法使其在我的機器上工作。 我在這里做錯了什么?
使用瀏覽器中的調試控制台(按F12),以及JSFiddle中的JSHint按鈕。 您的VM構造函數無效。 修復此問題后,您會發現您嘗試對不可觀察的內容使用subscribe
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.