2013-07-24 76 views
0

我正在使用帶有jQuery Mobile的Photoswipe圖庫。點擊時的第一個選擇只顯示帶有完整URL的圖像,不能以圖庫的方式工作。當我回去並再次選擇時,它工作正常。在第一次失敗/刷新頁面後,ps正在工作。PhotoSwipe在第一次加載頁面時不起作用

請檢查以下鏈接,它是我的移動網站。 http://w3qatar.info/aldarmobi

當我們檢查鏈接屬性>從列表中的任何屬性>查看更多的照片...在這個你可以找到縮略圖。當我們首先點擊縮略圖時,它會加載原始圖像而不是圖庫視圖。但是當我們返回並重試時,它將起作用。我正在使用Opera移動模擬器進行測試。帶有Mobile_jquery主題的Drupal 7。本站使用jquery mobile。

內部代碼:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script> 
    <link href="http://w3qatar.info/aldarmobi/sites/all/themes/mobile_jquery/photoswipe.css" type="text/css" rel="stylesheet" /> 
    <script type="text/javascript" src="http://w3qatar.info/aldarmobi/sites/all/themes/mobile_jquery/lib/klass.min.js"></script> 
    <script type="text/javascript" src="http://w3qatar.info/aldarmobi/sites/all/themes/mobile_jquery/scripts/code.photoswipe.jquery-3.0.5.min.js"></script> 

<script type="text/javascript"> 

(function(window, PhotoSwipe){ 

      document.addEventListener('DOMContentLoaded', function(){ 

     var 
       options = {}, 
       instance = PhotoSwipe.attach(window.document.querySelectorAll('#gallery li a'), options); 

     }, false); 

     }(window, window.Code.PhotoSwipe)); 

    </script> 

HTML的一部分:

<ul id="gallery" class="gallery"> 
<li><a href="imageurl1" rel="external"><img src="imageurl1" alt="image name1" /></a></li> 
<li><a href="imageurl2" rel="external"><img src="imageurl2" alt="image name2" /></a></li> 
<li><a href="imageurl3" rel="external"><img src="imageurl3" alt="image name3" /></a></li> 
<li><a href="imageurl4" rel="external"><img src="imageurl4" alt="image name4" /></a></li> 
</ul 

你能幫幫我嗎? 我想在iPhone設備和Android手機上工作。

在此先感謝。

harikris。

+0

有時候,我找到了新的錯誤「未捕獲的異常:Code.PhotoSwipe.createInstance:無圖像傳遞」。 – Harikrishnan

回答

0

我使用jQuery顯示你的代碼,爲什麼不用它做任何事情。

你可以改變你的代碼像下面看看它的工作原理或不

(function(window, $, PhotoSwipe){ 

    $(document).ready(function(){ 

     $('div.p-img_more') 
      .live('pageshow', function(e){ 

       var 
        currentPage = $(e.target), 
        options = {}, 
        photoSwipeInstance = $("ul.gallery a", e.target).photoSwipe(options, currentPage.attr('id')); 

       return true; 

      }) 

      .live('pagehide', function(e){ 

       var 
        currentPage = $(e.target), 
        photoSwipeInstance = PhotoSwipe.getInstance(currentPage.attr('id')); 

       if (typeof photoSwipeInstance != "undefined" &amp;&amp; photoSwipeInstance != null) { 
        PhotoSwipe.detatch(photoSwipeInstance); 
       } 

       return true; 

      }); 

    }); 

}(window, window.jQuery, window.Code.PhotoSwipe)); 
+0

hello, 我添加了上面的代碼,但它在第一次加載或下一頁刷新時不起作用。你可以請檢查它... – Harikrishnan

+0

我認爲其相關的jqm文件調用..缺少那裏... ... – Harikrishnan

相關問題