TinyMCE:API/tinymce.Editor/onSetContent
From Moxiecode Documentation Wiki
Contents |
[edit]
Event: onSetContent
[edit]
Summary
This event gets executed when the setContent method is called and after the serialization with preProcess and postProcess has been completed. This event enables you to change the contents before it gets placed in the editor this is very similar to the onPostProcess event but this only occurs when the setContent method is called.
[edit]
Syntax
event_callback(<tinymce.Editor> ed, <Object> o)
[edit]
Parameters
- ed
- Sender object/Editor instance that is serializing an element.
- o
- Object containing things like the contents that will be stored.
[edit]
Examples
// Adds an observer to the onSetContent event using tinyMCE.init
tinyMCE.init({
...
setup : function(ed) {
ed.onSetContent.add(function(ed, o) {
// Replaces all a characters with b characters
o.content = o.content.replace(/a/g, 'b');
});
}
});
// Adds an observer to the onSetContent event using the render method
var ed = new tinymce.Editor('someid', {
.. Some settings
});
ed.onSetContent.add(function(ed, o) {
// Replaces all a characters with b characters
o.content = o.content.replace(/a/g, 'b');
});
ed.render();
