我有一个像这样的ko maaaped数组。按钮单击保存在KO
var Type = [];
Type.push("Flip");
Type.push("Bar");
Type.push("Foo");
// converting the json to ko mapped collection
viewModel = {
firstValue: ko.observable("hello"),
Type: ko.mapping.fromJS(Type),
save: function() {
alert(viewModel.Type[0]);
alert("have to save the values here");
},
};
我用foreach来创建一个输入来编辑该数组。
<div data-bind="foreach: Type">
<p><input data-bind='value: $parent.Type()[$index()]' /></p>
<button data-bind='click: save'> Save </button>
我想保存编辑后的值回按钮点击阵列,,而不是保存该instantlly。如何实现这一目标?
很好的答案..我已经根据你提到的精彩文章更新了你的例子。请在 –