Make sure not to reference inexistent element/scope
Introduce state variable for state of popup
Merge pull request #343 from geoadmin/dev_popup_robust

Make sure not to reference inexistent element/scope