Fix external links in popup dialogs

This PR relates to issues #219 and #41.

Because the HTML for popup dialogs doesn't exist when the page is loaded, the ready() callback which causes external links to be opened in a new tab/window wasn't able to set the appropriate action on &lt;a&gt; tags.

This PR adds that functionality to refresh_buttons(), which is called everywhere such action is needed.