title: PhotoSwipe is not working on first time page load
body: <p>I am using Photoswipe gallery with jQuery Mobile. The first selection, when clicked shows just the image with full URL and does not work the gallery way. When I go back and select again, it works fine.The ps is working after a first failure/refresh of page.</p>
  
  <p>Please check the link below.it's my mobile website.
  <a href="http://w3qatar.info/aldarmobi" rel="nofollow">http://w3qatar.info/aldarmobi</a></p>
  
  <p>When we check the link Properties> any property from the list > View more photos ... under this you can find the thumbnails. When we click the thumbnail first it will load the original image without gallery view.But when we go back and try again ,it will work.i'm using opera mobile emulator for testing. Drupal 7 with Mobile_jquery theme. Jquery mobile is used in this site.</p>
  
  <p><strong>inside code:</strong></p>
  
  <pre><code>&lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"&gt;&lt;/script&gt;
    &lt;link href="http://w3qatar.info/aldarmobi/sites/all/themes/mobile_jquery/photoswipe.css" type="text/css" rel="stylesheet" /&gt;  
    &lt;script type="text/javascript" src="http://w3qatar.info/aldarmobi/sites/all/themes/mobile_jquery/lib/klass.min.js"&gt;&lt;/script&gt;  
    &lt;script type="text/javascript" src="http://w3qatar.info/aldarmobi/sites/all/themes/mobile_jquery/scripts/code.photoswipe.jquery-3.0.5.min.js"&gt;&lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
  
  (function(window, PhotoSwipe){
  
              document.addEventListener('DOMContentLoaded', function(){
  
          var
                  options = {},
                  instance = PhotoSwipe.attach( window.document.querySelectorAll('#gallery li a'), options );
  
          }, false);
  
          }(window, window.Code.PhotoSwipe));
  
      &lt;/script&gt;
  </code></pre>
  
  <p><strong>html part:</strong> </p>
  
  <pre><code>&lt;ul id="gallery" class="gallery"&gt;
  &lt;li&gt;&lt;a href="imageurl1" rel="external"&gt;&lt;img src="imageurl1" alt="image name1" /&gt;&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="imageurl2" rel="external"&gt;&lt;img src="imageurl2" alt="image name2" /&gt;&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="imageurl3" rel="external"&gt;&lt;img src="imageurl3" alt="image name3" /&gt;&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="imageurl4" rel="external"&gt;&lt;img src="imageurl4" alt="image name4" /&gt;&lt;/a&gt;&lt;/li&gt;
  &lt;/ul
  </code></pre>
  
  <p>Could you please help me?
  I want to work this in iPhone devices and android phones.</p>
  
  <p>thanks in advance.</p>
  
  <p>harikris.</p>