Event Hooks
Blackbeard emits custom JavaScript events that you can hook into to run scripts and further customize your Portal.
Use `addEventListener()` on the `window` element to listen for Portal events.
```js
window.addEventListener('portalAfterRender', function (event) {
alert('The Portal was rendered!');
}, false);
```
## Events
- `portalLoaded` runs after the Portal app is loaded but before it's been initialized.
- `portalBeforeInit` runs before the Portal is initialized.
- `portalAfterInit` runs after the Portal is initialized.
- `portalBeforeRender` runs before the Portal is rendered.
- `portalAfterRender` runs after the Portal is rendered.
- `portalBeforeRenderAjax` runs before an Ajax page load.
- `portalAfterRenderAjax` runs after an Ajax page load.
- `portalIODocsShowMethod` runs after an IO-Docs method is shown.
- `portalIODocsHideMethod` runs after an IO-Docs method is hidden.
- `portalIODocsShowEndpoint` runs after an IO-Docs endpoint is shown.
- `portalIODocsHideEndpoint` runs after an IO-Docs endpoint is hidden.
## Emitting your own custom events
Blackbeard also includes [a JavaScript API for emitting your own custom events](/docs/read/your_portal/layout_and_design/JavaScript_API#emitevent).
```js
// A simple event
m$.emitEvent('myCustomEvent');
// An event with Details
m$.emitEvent('anotherCustomEvent', {
details: {
something: 'a value',
another: true,
answer: 42
}
});
```
Docs Navigation
- API Documentation Portal
- IO Docs Definition
- Mashery API Documentation
- Mashery 3.0 API Guide
- Mashery 2.0 API Guide
- OAuth Supporting Methods
- Examples
- JSON RPC
- Authentication
- API Objects
- Fetching Objects
- Query Language
- Creating Objects
- Updating Objects
- Validating Fields
- Deleting Objects
- Applications
- General Object Methods
- Members
- Packages
- Plans
- Package Keys
- Keys
- Developer Classes
- Services
- Roles
- Mashery 2.0 Reporting API Guide
- Event Trigger API
- Differences between Roles and Portal Access Groups
- Managing a Portal Access Group Using Mashery V2 or V3 API
- Mashery Reporting Event Post API Guide
- Tips and Tricks
- Your Portal
- API Traffic Manager
- I/O Docs WSDL requirements