[英]how to restore back data in template using knockout.js
I want to build a template like gridview. 我想建立一个像gridview的模板。 My problem is when I edit the data '123qwe' to '123' but when i click 'cancel' button not to edit the data.
我的问题是,当我将数据“ 123qwe”编辑为“ 123”时,但是当我单击“取消”按钮不编辑数据时。 the data not restore back to '123qwe'.
数据无法还原回“ 123qwe”。 I have a workaround to solve this, however, it is not work in my computer but in jsfiddle, I want to know the reason and help to solve in a knockout.js format.
我有一种解决方法来解决此问题,但是,它在我的计算机上不起作用,但在jsfiddle中不起作用,我想知道原因并帮助您使用淘汰表.js格式解决。 Thank you~~~
谢谢~~~
code to attention: 注意代码:
// Reset button
self.reset = function (index) {
self.nameLists([]);
$.each(og_arr, function(i,item){
self.nameLists.push(new nameFilter(item.name));
});
this.editTemplate("readOnlyTemplate");
};
There is no built-in notion of canceling an edit. 没有内置的取消编辑的概念。 You are editing an observable.
您正在编辑可观察对象。 Have a look at protected observables , a simple extension that allows you to commit or reset a change.
看一下受保护的observables ,这是一个简单的扩展,可让您提交或重置更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.