⚡ Event Handling
ContentBox.js provides several built-in event hooks that allow you to respond to user actions and content changes in real time. These events are useful for integrating with external systems or applying custom logic.
🔄 onRender – Triggered When Content Is Updated or Re-rendered
This event is fired whenever the content structure changes — such as when a new snippet is added, a block is moved, or layout changes occur.
Use it to re-apply custom scripts or behaviors after content updates.
Example:
const builder = new ContentBox({
/* options */
onRender: function() {
console.log('Content structure updated');
}
});
📝 onChange – Triggered When Content Is Edited
This event fires whenever the actual content is modified — for example, when text is typed, formatted, or deleted.
Useful for auto-saving content.
Example:
const builder = new ContentBox({
/* options */
onChange: function() {
console.log('Content was edited');
}
});
✅ onStart – Triggered When Editor Is Initialized
This event is called once when the editor has fully loaded and is ready for interaction.
Useful for initializing external integrations or UI enhancements after the editor starts.
Example:
const builder = new ContentBox({
/* options */
onStart: function() {
console.log('Editor has started');
}
});