The "undo" functionality is part of the Fluid framework. It can be used to provide undo support for any component that bears a model.
Currently, the Fluid components that support Undo are:
This page discribes:
- how to enable undo on components that support it, and
- how to build undo support into a component that you are creating.
Enabling Undo on Components that Support it
There are two ways to enable Undo on components that support it:
- Specify the undo decorator as an option to the component creation
- Manually create the undo decorator
Using the componentDecorators option
The simplest way to enable Undo functionality on a component that supports it is to use the
This section is currently incorrect.
Example - Inline Edit
Requesting the "fluid.undoDecorator" will automatically enable the Undo functionality, and the component will be decorated with the necessary controls, etc.
For more control and flexibility, an Undo decorator can be manually created.
component parameter is a standard Fluid component to receive the "undo" functionality.
The object can contain any subset of the following keys:
a function that renders the markup for the undo controls
Building Undo Support into a Component
Component developers must ensure that their component has certain features for Undo to work with it. A component must:
- Bear a model
- Initialize the Undo decorator if requested
- is 'public,' i.e. as a return available from the component's top-level "that", or else stored within its DOM instance using jQuery.data under a well-known value.
The actual contents of a model is, of course, entirely dependent on the component.
A model must have:
- a renderer
A component must maintain a list of 'listeners' who may subscribe to model-directed events representing updates to the model. The Fluid Framework provides an Event Firer that can be used for this:
modelFirer provides three functions:
Listeners registered using this function are notified when the model changes.
- The Undo decorator registers a listener using this function.
- The component is responsible for calling
fireEvent()when the model changes.
The component must implement a no-argument function called
This function should "re-render" the component, reflecting any changes in the model.
- The Undo decorator calls this function when an action is 'un-done' or 're-done.'
Initializing the Undo decorator
A component must respond to a user-supplied option requesting Undo by initializing the Undo decorator. This is accomplished by using the
initComponents() framework function: