Я привязываю некоторые элементы списка к выпадающему меню нокаутом, но это не является обязательным. Я не знаю, где я ошибаюсь.Knockout Binding
Я использовал плагин отображения нокаута и даже попробовал простой метод, но ничего не работает.
Моя основная структура такова:
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);
Konck вне. Тей хи. – spender
Пожалуйста, приложите немного усилий для правильного форматирования и написания ваших вопросов. –