So I do like this when user click a button:

var popup = $popup.create(url, features, options);

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)

c.popup = $popup.create(url, features, options);
  • 3
    Only to add that the possible action to do when the popup is already open is c.popup.focus(); to bring it to the front view – Raúl Escudero Jan 22 '16 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.