如何回滚Backbone.js的模型的变化? [英] How to rollback backbone.js model changes?

查看:147
本文介绍了如何回滚Backbone.js的模型的变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的页面上的取消按钮,这应该恢复我做回它从服务器加载状态的所有更改。

I have a "Cancel" button on my page which should reverts all the changes I made back to the state it was loaded from server..

我想我需要存储Backbonejs模型的初始状态和恢复电流(改变)状态恢复到初始值。

I guess I need to store an initial state of Backbonejs model and restore a current (changed) state back to initial.

什么是实现这一目标的最佳途径?

What is the best way to achieve that?

感谢您

推荐答案

FWIW - 我写了一个插件来自动处理,特别是与取消记住按钮的理念:<一href=\"http://github.com/derickbailey/backbone.memento\">http://github.com/derickbailey/backbone.memento

FWIW - i wrote a plugin to handle this automatically, specifically with the idea of "cancel" buttons in mind: http://github.com/derickbailey/backbone.memento

这篇关于如何回滚Backbone.js的模型的变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆