简体   繁体   English

如何使用基因敲除恢复模板中的数据

[英]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");
}; 

program in jsfiddle jsfiddle中的程序

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 ,这是一个简单的扩展,可让您提交或重置更改。

For general "undo" functionality, check out the Memento plugin for Knockout. 对于常规的“撤消”功能,请查看Knockout的Memento插件。

(I didn't write it, just a satisfied user) (我没有写,只是一个满意的用户)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM