我有多个网格,我想在一个提交按钮下运行。这是代码:http: //jsfiddle.net/aETvS/
我收到错误“无法读取未定义的属性‘推送’”
self.orders = ko.observableArray(orders);
self.addorder = function() {
self.orders.push({
name: "",
price: ""
});
};
self.removeorder = function(order) {
self.orders.remove(order);
};
self.hardware = ko.observableArray(hardware);
self.addhardware = function() {
self.hardware.push({
name: "",
price: ""
});
};
self.removehardware = function(hardware) {
self.hardware.remove(hardware);
};
self.save = function(form) {
alert("Could now transmit to server: " + ko.utils.stringifyJson(self.orders));
// To actually transmit to server as a regular form post, write this: ko.utils.postJson($("form")[0], self.orders);
};