我通过Knockout将一些列表项绑定到下拉列表中,但它不具有约束力。我不知道我要去哪里错..敲除绑定
我用淘汰赛映射插件,甚至尝试了一个简单的方法,但似乎没有任何工作。
我的基本结构是这样的:
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 2013-02-19 12:19:02
请为正确格式化和拼写问题付出一些努力。 – 2013-02-19 12:22:20