Search code examples
javascriptonsen-uionsen-ui2

Onsen UI, how to use isShow() Method


I'm creating a very simple app, and I'm using Onsen UI and purely JavaScript (no Angular, React, or Vue). This is the first time a use this framework, but so far seems pretty simple and straight forward, except the isShow() method. I have a dialog that I open using:

document.getElementById(id).show({ animation: "fade" });

But now I need to know how to check if the dialog is open or not. I thought that using something like this would work:

console.log(document.getElementById(id).isShown());

But I get a document.getElementById(...).isShown is not a function error message.The only thing I can find is what is says inn the Onsen UI documentation: isShown() Returns whether the popover is visible or not.

How can I determine if a Dialog <ons-dialog> element is open (visible) in Onsen UI?


Solution

  • The isShown() method was part of Onsen UI v1. For v2 you can access visible property and get the same value. Docs here.