Modal is an abstract base class for creating Bootstrap modals with lifecycle hooks.
Extend this class and implement init(), render(), and afterRender() methods.
Call show() to open the modal and hide() to close it with an optional response value.
Import
import {components} from 'metronic-extension';
const {Modal} = components;
Lifecycle Hooks
Implement these methods in your subclass:
Hook
Return
Description
init(...params)
Promise<void> | void
Called before the modal is shown. Use for data fetching and initialization.
render(...params)
Promise<string> | string
Returns the modal's HTML content.
afterShown()
void
Called after the modal is fully shown (after CSS transitions).
afterHidden()
void
Called after the modal is fully hidden.
Methods
Method
Return
Description
show(...params)
Promise<any>
Opens the modal. Parameters are passed to lifecycle hooks. Returns a response when the modal is closed.
hide(response?)
void
Closes the modal. Optional response value is returned by show().
isShowing()
boolean
Returns true if the modal is currently shown.
Basic Example
A simple modal that receives a title parameter and displays it. Click the button to open the modal.