Opens a dashboard modal extension.
This function can only be used in page code files for dashboard pages created in the Wix editor or with Wix Blocks.
The openModal()
function returns an object with a property called modalClosed
. This property is a promise that resolves to the data passed to closeModal()
when the modal is closed.
Note: Before you use this function, you need a dashboard modal extension. Learn more about implementing dashboard modal extensions.
function openModal(modalId: string, modalParams: object): OpenModalReturn;
ID of the dashboard modal extension to open.
Custom data to pass into the extension. The extension can access this data using observeState()
.
import { openModal } from "wix-dashboard";
/* Sample modalID: '1d52d058-0392-44fa-bd64-ed09275a6fcc' */
const { modalClosed } = openModal("myModalId");
modalClosed
.then((closeData) => {
console.log("The modal was closed and returned: ", closeData);
})
.catch((error) => {
console.error(error);
// Handle the error
});
/* The value of `modalClosed` resolves to an object containing the data passed in when the modal is closed. */
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.