私はこのようなko maaaped配列を持っています。
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>
編集した値をすぐに保存するのではなく、ボタンのクリックで配列に保存したい。これを達成する方法は?