2012-09-24 7 views
1

jQuery Mobile의 Photoswipe 갤러리를 사용하고 있습니다. 첫 번째 선택은 클릭/탭하면 전체 URL이 포함 된 이미지 만 표시되고 갤러리 방식으로는 작동하지 않습니다. 다시 돌아가서 다시 선택하면 정상적으로 작동합니다.Photoswipe 갤러리의 첫 번째 선택이 작동하지 않습니다.

아무쪼록이 문제를 어떻게 해결할 수 있습니까?

건배!

답변

1

사용자가 사진 닦이 갤러리 페이지로 직접 연결하면 photoswipe 링크가 초기화되지 않습니다. 예를 들어 직접 링크를 사용하는 공식 데모로이 문제를 렌더링 할 수도 있습니다. 링크 : http://www.photoswipe.com/latest/examples/04-jquery-mobile.html#Gallery1

photoswipe가 pageshowpagehide 이벤트 처리기를 부착하는 스크립트를 넣어보십시오. jquery-mobile.js 앞에 입력하십시오. 핸들러가 연결되면 처음 방문한 사용자는 페이지를 방문하지 않습니다.

<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

이것은 나를 위해 작동하지 않았다. –

관련 문제