jQuery Mobile AJAX navigation to a page having a dialog

jQuery Mobile AJAX navigation to a page having a dialog

JQM AJAX navigation doesn't work well when navigating to a page with an in-page dialog?

page1.aspx:

<div data-role="page">   <div data-role="header">Page 1</div>
  <div data-role="content">
    <a href='page2.aspx'>Click here</a>
  </div>
</div>

page2.aspx:

<div data-role="page">  <div data-role="header">Page 2</div>  <div data-role="content">  <a href='#popup' data-rel="dialog">Popup</a>  </div> </div><div data-role="dialog" id='popup'> <!-- This is not loaded on AJAX navigation -->  <div data-role="header">Page 2 Popup</div>  <div data-role="content">Popup content</div> </div>

When you click the link from Page 1, it doesn't load the <div data-role='dialog'> of Page 2.

How do you get around this issue?