ノックアウトを使用していくつかのリスト項目をドロップダウンにバインドしていますが、バインドされていません。どこが間違っているのかわかりません..
ノックアウト マッピング プラグインを使用し、簡単な方法も試しましたが、何もうまくいかないようです。
私の基本的な構造は次のようなものです:
BugsReport rp = new BugsReport()
{
SoftwareProductList = new List<SoftProduct>() { new SoftProduct() { ProductName = "eCommerce Website", SoftProId = 1 }, new SoftProduct() { ProductName = "Banking website", SoftProId = 2 } },
ListBugs = GetAllBugs(),
PriorityLevels = new List<Priority>() { new Priority() { PriorityId = 1, PriorityName = "P1" }, new Priority() { PriorityId = 2, PriorityName = "P2" }, new Priority() { PriorityId = 3, PriorityName = "P3" } }
};
コントローラーから送信しています...通常のかみそりのバインドは発生していますが、ノックアウトは発生していません。
HTML部分
<div style="margin-top: 10px; width: 200px; float: left; font-weight: bold;">
Products
<select id="slSoftProducts" multiple="multiple" data-bind="options: $root.ProductList, value:ProductList.SoftProId, optionsText: 'ProductList.ProductName'">. </select>
</div>
<div style="margin-top: 10px; width: 200px; float: left; font-weight: bold; margin-left: 30px;">
priority Levels
<select id="slPriorityLevels" multiple="multiple" data-bind="options: $root.priorityList, value: priorityList.PriorityId, optionsText: 'priorityList.PriorityName'"></select>
</div>
およびJavascript部分
function bugzillaviewmodel(){
var self = this;
self.ProductList = BugList.SoftwareProductList;
self.priorityList = BugList.PriorityLevels;
}
var viewModel = new bugzillaviewmodel();
// Knock Out Binding through mapping..
//var viewModel = ko.mapping.fromJS(BugList);
ko.applyBindings(viewModel);