In AriaTemplates, popups are widgets, it means you get to open a popup from within a template, using the following syntax:

{@aria:Dialog{ ... }/}

And you would then bind the visible property of that widget to some value in the data model in order to decide when the popup is visible and when it is hidden.

This might look like a strange approach for a lot of people used to somewhat more standard DOM manipulation approaches where a popup is most of the time considered as something you trigger through javascript and which offers a placeholder to display content.

Well, it turns out that the way the AT popup is done kind of allows this. The only tricky part is the fact that since popups are used in templates, they know how to display content coming from templates, namely, sections.

To work around this, we can very easily mock a section object, and instantiate a popup object using the AT aria.popups.Popup class. I know it’s not very clean, but does work.
Consider the code below:

Note that the config object passed to these 2 methods can accept any of the popup config properties (except the section obviously, because we are creating a mock one dynamically).

Note as well that the aria.popups.Popup class itself is not responsible for the markup and styling of the popup container, so by default, you’ll just get your content in the middle of the screen. You might be interested in using the {@aria:Div {sclass:"dlg"} /} widget to make it look like the normal AT dialog.

Tell me if you think this is a feature that the framework should provide out of the box?