2012-09-24 40 views
1

我正在使用與jQuery Mobile的Photoswipe圖庫。第一個選擇,點擊/點擊時只顯示帶有完整網址的圖片,不能以圖庫的方式工作。當我回去再選擇時,它工作正常。Photoswipe圖庫中的第一個選項不起作用

任何人都可以告訴我如何解決這個問題?

乾杯!

回答

1

當用戶直接使用鏈接p​​hotoswipe進入photoswipe圖庫頁面時未初始化。例如,即使使用直接鏈接進行官方演示也會導致此問題。鏈接:http://www.photoswipe.com/latest/examples/04-jquery-mobile.html#Gallery1

請嘗試放入腳本,其中0123w之前的照片管理器將pageshowpagehide事件附加到處理程序。如果處理程序在第一次用戶訪問頁面後不會被觸發,則連接。

<script type="text/javascript" src="code.photoswipe-3.0.5.min.js"></script> 
<script type="text/javascript"> 
    (function(window, $, PhotoSwipe){ 

     $(document).ready(function(){ 
      $('div.gallery-page') 
       .live('pageshow', function(e){ 
        if($('ul.gallery', e.target).length > 0){ 
         var 
          currentPage = $(e.target), 
          options = {}, 
          photoSwipeInstance = $("ul.gallery a", e.target).photoSwipe(options, currentPage.attr('id')); 

          return true; 
        } 
       }) 

       .live('pagehide', function(e){ 
        if($('ul.gallery', e.target).length > 0){ 
         var 
          currentPage = $(e.target), 
          photoSwipeInstance = PhotoSwipe.getInstance(currentPage.attr('id')); 

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

         return true; 
        } 

       }); 

     }); 

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

</script> 
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script> 
+0

這對我來說非常合適。不要忘記修改「div.gallery-page」和「ul.gallery」。 – TeChn4K

+0

這不適合我 –

相關問題