While working with Webix data components, you can enable the undo functionality that allows reverting changes in case the server returns an error message.
The undo operation can be applied to any DataStore-based component.
To enable undo, you need to set the undo property to true in the configuration of the component. You can set the limit of the number of operations to revert with the help of undoLimit:
webix.ui({
view:"list",
id:"mylist",
template:"#title#",
data:dataset,
undo:true,
undoLimit:40
});
The undo API includes three methods:
$$("mylist").undo();
For example, if you add an item into the component, then change it and finally decide to delete it, a call of the undo() method will revert just the result of the delete operation.
If you want to delete all the changes performed on an item and set it to the initial state, you should pass the id of this item to the undo() method.
$$("mylist").removeUndo(id);
The method takes the id of an item as its parameter.
$$("mylist").ignoreUndo(function(){
$$("mylist").addItem({...});
});
The ignoreUndo() method takes as a parameter the function for which the undo history track should be disabled.
Back to top