O'Reilly logo

Backbone.js Cookbook by Vadim Mirgorod

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating undo points to store/restore a model's state

Sometimes, you may need to manage the states of a model in your application. This can be useful in one of the following cases:

  • Your application requires an undo/redo feature
  • You want to implement transactions
  • Your application emulates some process
  • You want to change a model temporarily and then restore it

Typically for all of the previous cases developers often use the Memento pattern. There is an implementation of this pattern in Backbone, which is available in the Backbone.Memento extension. This extension allows developers to store or restore a model's state and provides a stack for operating with multiple states.

Getting ready

You can download the Backbone.Memento extension from the GitHub page ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required