TinyMCE:API/tinymce.Editor/onNodeChange
From Moxiecode Documentation Wiki
Contents |
[edit]
Event: onNodeChange
[edit]
Summary
This event gets executed when the nodeChanged method is called. This event occurs when the user moves the caret inside the editor or after a command like Bold is executed. This enables you to update the UI with new states depending on where the caret is. For example after a bold command you might want to activate the bold button in the toolbar.
[edit]
Syntax
event_callback(<tinymce.Editor> ed, <tinymce.ControlManager> cm, <Element> e, <Boolean> c, <Object> o)
[edit]
Parameters
- ed
- Sender object/Editor instance that is serializing an element.
- cm
- Control manager for the node change event.
- e
- Current element the same as calling the editor.selection.getNode method.
- c
- Is collapsed true/false state. The same as calling the editor.selection.isCollapsed method.
- o
- Optional object containing other custom things passed into the nodeChanged method call.
[edit]
Examples
// Adds an observer to the onNodeChange event using tinyMCE.init
tinyMCE.init({
...
setup : function(ed) {
ed.onNodeChange.add(function(ed, cm, e) {
// Activates the link button when the caret is placed in a anchor element
if (e.nodeName == 'A')
cm.setActive('link', true);
});
}
});
// Adds an observer to the onNodeChange event using the render method
var ed = new tinymce.Editor('someid', {
.. Some settings
});
ed.onNodeChange.add(function(ed, o) {
// Activates the link button when the caret is placed in a anchor element
if (e.nodeName == 'A')
cm.setActive('link', true);
});
ed.render();
