Tutorial: View.bindToElement

View.bindToElement

NOTE: Internal use only.

Attaches a view to a DOM element. View will resize accordingly when the element is resized. If the element is repositioned in the DOM the view will not be repositioned, to handle this case call bindToElement again once the element changes position.

Example

<div id="view-container"></div>
<script>
    async function createAndAttachView() {
        const url = 'https://example.com';
        const elementId = 'view-container';
        const element = document.getElementById(elementId);
        const view = await fin.View.create({
            name: 'my-view',
            url,
            target: fin.me.identity
        });
        await view.navigate(url);
        await view.bindToElement(element);
    }
    createAndAttachView().catch(console.error);
</script>