Welcome to the Widget Events Guide! This guide will help you understand how to handle events in widgets. Widgets are a powerful feature in our platform, allowing you to extend and customize your applications.
Events Overview
Widgets can emit various events to communicate with the parent application. Here are some common events:
- Click: Triggered when the widget is clicked.
- Resize: Triggered when the widget is resized.
- Load: Triggered when the widget is loaded.
- Unload: Triggered when the widget is unloaded.
Handling Events
To handle events in a widget, you can define event handlers. Event handlers are functions that are called when an event is triggered.
Example
widget.on('click', function() {
console.log('Widget was clicked!');
});
Advanced Features
Custom Events
You can also create custom events for your widgets. This is useful when you need to communicate specific information to the parent application.
widget.emit('customEvent', { message: 'Hello, parent app!' });
Event Bubbling
Events can bubble up the widget hierarchy. This means that if an event is triggered in a child widget, it will also be triggered in the parent widget.
widget.on('click', function() {
console.log('Widget was clicked!');
parentWidget.emit('click');
});
Further Reading
For more information on widgets and events, please refer to our Widget Development Guide.