Keep a Popover Open on Page Refresh

In a PHP web application, we often want to open a popover using JavaScript, say a jQueryUI Dialog widget.

What happens when a page reloads, say by periodic refresh? The popover disappears!

To preserve the popover open on page refresh, store in the session storage, all data required to create the dialog before showing the dialog.

On page reload, create the dialog again, using the data from the session storage. This is done by setting an onload callback on the body tag:

and recreating the popover in the function createPopover.

This techniques works not just for jQueryUI but for any JavaScript based framework.