So I do like this when user click a button:
var popup = $popup.create(url, features, options);
popup.open();
The problem is that every time the user clicks, a new popup is opened. I tried popup.isOpen() but is always false.
isOpen()
is the correct method to call. It will return true
any time in between the open()
method being called and the close()
method being called.
Maybe you are creating a new popup every time and that's why it is always false
? You should keep the variable around (usually in this.properties) and check for null
and isOpen()
before you create a new popup.
Something like this:
var c = this.properties.controls;
if (c.popup && c.popup.isOpen())
{
// Already open - do something (e.g. send new parameters to it)
return;
}
c.popup = $popup.create(url, features, options);
c.popup.open();