TinyMCE:API/tinymce.Editor/onBeforeSetContent
From Moxiecode Documentation Wiki
Contents |
[edit]
Event: onBeforeSetContent
[edit]
Summary
This event gets executed when the setContent method is called but before the contents gets serialized and placed in the editor. This event is useful when you want to change for example BBCode into HTML code before setting it to the document DOM.
[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 onBeforeSetContent event using tinyMCE.init
tinyMCE.init({
...
setup : function(ed) {
ed.onBeforeSetContent.add(function(ed, o) {
// Replaces all a characters with b characters
o.content = o.content.replace(/a/g, 'b');
});
}
});
// Adds an observer to the onBeforeSetContent event using the render method
var ed = new tinymce.Editor('someid', {
.. Some settings
});
ed.onBeforeSetContent.add(function(ed, o) {
// Replaces all a characters with b characters
o.content = o.content.replace(/a/g, 'b');
});
ed.render();
