This method updates a modal window previously opened using the
CondoWebAppShowModalWindow
method.Platforms
- B2B-Web
Method params
Parameter name | Parameter type | Required | Parameter description |
---|---|---|---|
modalId | string | yes | ID of the modal window to be updated |
data | JSON | yes | JSON containing parameters to be changed and their new values. Any window parameters described in the CondoWebAppShowModalWindow method can be changed, except for the link to the internal iframe (For this you can simply redirect the user inside the already opened iframe). |
If it is necessary to update a modal window from the main application window, the
modalId
parameter can be retrieved
in the response of the CondoWebAppShowModalWindow
method.
If you need to update a modal window from an iframe opened in a modal window, then the modalId
parameter can be found
in the query-parameters of this iframe.Return value
If successful, the method will return a JSON object containing a single
updated
field:json{ "updated": true }
Usage examples
Below is an example of updating a modal window from the main page of a mini-application and from modal window iframe :
From main app window
From modal window
typescript// pages/index.tsx import React, { useCallback, useState, useEffect } from 'react' import bridge from '@open-condo/bridge' import { Button } from '@open-condo/ui' export default function MiniappPage (): React.ReactNode { const [openModalId, setOpenModalId] = useState<string | null>(null) const openModal = useCallback(() => { bridge.send('CondoWebAppShowModalWindow', { url: 'http://localhost:3001/modal', size: 'small', title: 'Loading...', }).then((data) => { setOpenModalId(data.modalId) }) }, []) useEffect(() => { if (openModalId) { setTimeout(() => { bridge.send('CondoWebAppUpdateModalWindow', { modalId: openModalId, data: { title: 'Welcome' } }) }, 1000) } }, [openModalId]) return ( <Button type='primary' onClick={openModal}>Open modal window</Button> ) }