【发布时间】:2014-03-23 22:06:21
【问题描述】:
http://jsfiddle.net/descending/adNuR/2523/
这是 Knockout Js 汽车编辑器示例,我添加了一个东西,即获取信息链接。当用户单击获取信息时,我需要能够添加项目并获取该行的选定项目。
我到底如何才能做到这一点?我被难住了
var CartLine = function () {
var self = this;
self.category = ko.observable();
self.product = ko.observable();
self.quantity = ko.observable(1);
self.subtotal = ko.computed(function () {
return self.product() ? self.product().price * parseInt("0" + self.quantity(), 10) : 0;
});
// Whenever the category changes, reset the product selection
self.category.subscribe(function () {
self.product(undefined);
});
};
【问题讨论】:
标签: javascript jquery knockout.js