我有下面的模型從淘汰賽觀察到
self.newItem = ko.observable({
manufacturer: ko.observable(),
itemnumber: ko.observable(),
itemDescription: ko.observable(),
priceclass: ko.observable(),
currentPrice: ko.computed(function() {
return "1.22";
}, this),
aeAuthority: ko.computed(function() {
return "1.02PC";
}, this),
requestedMinimumQuantity: ko.computed(function() {
return "!.22 PC";
}, this),
RequestedPrice: ko.observable(),
ExpirationDate: ko.observable(),
ItemDetails: ko.observable(),
Margin: ko.observable(),
Status: ko.observable()
});
我想清楚了這裏面可觀察到的數據,但是當我這樣做self.newItem = ""; or self.newItem('');
但去除的newitem裏面所有的觀測所以沒有財產清算出的數據留在newItem中。我可以單獨進入並清除newItem中的每個可觀察對象,但有沒有更好的方法來完成它。
感謝
你是問如何刪除新項目的所有項目,然後放入一個空的項目,使他們能夠更新? – gh9
定義「清除」。另外,描述你正在嘗試實現的功能。很可能你正在嘗試做一些更好的解決方法。 – Tomalak
通過清除我的意思是使newItem內的所有observables像製造商=''一樣空。我把它映射到模態對話框中,所以當表單關閉時,我想清空新項目,這樣映射到像製造商或itemnumber這樣的數據的所有字段都變空了。 – sp9