Search...
openModal( )
Opens a dashboard modal extension.
Description
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.
Syntax
function openModal(modalId: string, [modalParams: Object]): OpenModalReturn
openModal Parameters
NAME
TYPE
DESCRIPTION
modalId
string
ID of the dashboard modal extension to open.
modalParams
Optional
Object
Custom data to pass into the extension. The extension can access this data using observeState()
.
Returns
Return Type:
OpenModalReturn
NAME
TYPE
DESCRIPTION
modalClosed
Promise<Serializable>
Resolves to the data passed to closeModal()
when the modal is closed.
Was this helpful?
Open a modal and log the data returned when it's closed
Copy Code
1import { openModal } from 'wix-dashboard';23/* Sample modalID: '1d52d058-0392-44fa-bd64-ed09275a6fcc' */45const { modalClosed } = openModal('myModalId')67modalClosed8 .then((closeData) => {9 console.log('The modal was closed and returned: ', closeData);10 })11 .catch((error) => {12 console.error(error);13 // Handle the error14 });1516/* The value of `modalClosed` resolves to an object containing the data passed in when the modal is closed. */
Pass data to a modal extension
Copy Code
1import { openModal } from 'wix-dashboard';23/* Sample modalID value: '1d52d058-0392-44fa-bd64-ed09275a6fcc'4 * Sample modalParams value5 * {6 * firstName: 'Name'7 * }8 */910const { modalClosed } = client.dashboard.openModal('myModalId', myModalParams)1112modalClosed13 .then((closeData) => {14 console.log('The modal was closed and returned: ', closeData);15 })16 .catch((error) => {17 console.error(error);18 // Handle the error19 });2021/* The value of `modalClosed` resolves to an object containing the data passed in when the modal is closed. */