need to load and reload the same page for making the links work

need to load and reload the same page for making the links work

hi im developing my first app using jquery mobile, and i have an issue with 2 pages, in both pages if i load normally the page the link doesnt work, and if i reload the page the links works perfect.


in both web pages i have something like this:


  1. <!DOCTYPE html>
  2. <html lang="{country_code}">
  3. <head>
  4. <!-- META TAGS Declaration -->
  5. <meta charset="UTF-8">
  6. <title>MNT Graphic Design - About </title>
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0;" />
  8. <meta name="apple-mobile-web-app-capable" content="yes" />
  9. <meta name="author" content="MNT Graphic Design - http://www.mntdesign.co/" />
  10. <!-- CSS Declaration -->
  11. <link rel="stylesheet" type="text/css" href="{site_url}jquerymobile/css/jquery.mobile-1.3.1.css" />
  12. <link rel="stylesheet" type="text/css" href="{path='styles/m'}" />
  13. </head>

  14. <body>
  15. <div data-role="page" id="about" data-add-back-btn="true">
  16.  
  17.    
  18.    <div data-role="header" data-theme='a' id="header">
  19.        <h1> About Us </h1>
  20.    </div><!-- /header -->
  21.    <div data-role="content" data-theme='c' >
  22. <div class="choice_list"> 
  23. <ul data-role="listview" data-inset="true" >
  24. <li>
  25. <a href="#david" data-transition="slide"> 
  26. <h1>David</h1>
  27. <img src="http://www.mntdesign.co/uploads/imagenes/_thumb2/216346_10151483715269961_2029946791_n.jpg" alt="projectn1"/>
  28. <p> hello world! </p>
  29. </a>
  30. </li>
  31. <li>
  32. <a href="#alejandro" data-transition="slide"> 
  33. <h1>Alejandro</h1>
  34. <img src="http://www.mntdesign.co/uploads/imagenes/_thumb2/216346_10151483715269961_2029946791_n.jpg" alt="projectn2"/>
  35. <p> hello world! </p>
  36. </a>
  37. </li>
  38. </ul>
  39. </div>
  40. <p class="copyright">Copyright &copy; MNT. Designed by <a href="http://www.mntdesign.co" class="ui-link">MNTDesign</a></p>

  41. </div><!-- /content -->
  42.  
  43.    <div data-role="footer" data-theme='a' >
  44. <nav data-role="navbar">
  45. <ul>
  46. <li><a href="{path='m'}" data-icon="home">Home</a></li>
  47. </ul>
  48. </nav>
  49.        
  50.    </div><!-- /Foother -->
  51.    
  52. </div><!-- /page -->

  53. <div data-role="page" id="david" >
  54. <header data-role="header">
  55. <h1>Project #1</h1>
  56. <a href="#about" data-icon="grid" data-iconpos="notext" data-transition="slide">David</a>
  57. </header>
  58. <h1>David</h1>
  59. <p>hello world!</p>
  60. </div><!-- Page David -->
  61. <div data-role="page" id="alejandro" >
  62. <header data-role="header">
  63. <h1>Project #2</h1>
  64. <a href="#about" data-icon="grid" data-iconpos="notext" data-transition="slide">Alejandro</a>
  65. </header>
  66. <h1>Alejandro</h1>
  67. <p>hello world!</p>
  68. </div><!-- Page Alejandro -->
  69. </body>
  70. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
  71. <script type="text/javascript" src="{site_url}jquerymobile/js/jquery.mobile-1.3.1.js"></script>
  72. <script type="text/javascript">
  73.    </script>
  74. </html>

in the second one i have a couple of galleries that i load using photoswipe with the same structure and the only different is the javascript that i use for load the galleries. how can i fix this? i dont want to load twice the same page in order to work.

photoswipe gallery javascript

  1. <script type="text/javascript">
  2. (function(window, $, PhotoSwipe){
  3. $(document).ready(function(){
  4. $('div.gallery-page')
  5. .on('pageshow', function(e){
  6. var 
  7. currentPage = $(e.target),
  8. options = {},
  9. photoSwipeInstance = $("ul.gallery a", e.target).photoSwipe(options,  currentPage.attr('id'));
  10. return true;
  11. })
  12. .on('pagehide', function(e){
  13. var 
  14. currentPage = $(e.target),
  15. photoSwipeInstance = PhotoSwipe.getInstance(currentPage.attr('id'));
  16. if (typeof photoSwipeInstance != "undefined" && photoSwipeInstance != null) {
  17. PhotoSwipe.detatch(photoSwipeInstance);
  18. }
  19. return true;
  20. });
  21. });
  22. }(window, window.jQuery, window.Code.PhotoSwipe));
  23.    </script>