updateModel

Release 2.11.0 and above.

Refreshes the edit model based on the changed DOM.

Used to reflect the edited HTML DOM rendered on the screen into the edit model.

Parameters:

<table> <thead> <tr><th>Name</th><th>Type</th><th>Attribute</th><th>Description</th></tr> </thead> <tbody> <tr> <td><code>beforeId</code></td> <td>String</td> <td></td> <td>The ID value of the DOM before the change.</td> </tr> <tr> <td><code>afterId</code></td> <td>String</td> <td></td> <td>The ID value of the DOM after the change. Default value is <code>beforeId</code>.</td> </tr> <tr> <td><code>options</code></td> <td>Object</td> <td>
{
    skipUndoRedo: false,
    skipRendering: false
}
</td> <td>

Sets options for the APIModel.

  • skipUndoRedo: If true, edits made through this model are not added to undo/redo. The previous undo/redo stack is also cleared.
  • skipRendering: If true, edits made through this model are reflected only in the model and are not rendered to the screen. After all edits are completed, you must separately render via the editor.render() method.
</td> </tr> </tbody> </table>

Example:

When the ID is not changed

var p = document.getElementById('p1');
p.innerText = 'Change the text.';
editor.updateModel('p1');

When the ID is changed

var p1 = document.getElementById('p1');
p1.id = 'p2';
p2.innerText = 'Change the text.';
editor.updateModel('p1', 'p2');