2

Any ideas on why this isn't detaching my "homeSlider" instance of photoswipe on page change? I think I'm following the Photoswipe docs, but it doesn't seem to detach the instance. I'm using Jquery mobile hence the "pageshow"/"pagehide". It's throwing this error when I come back to the page and the slideshow freezes: "Code.PhotoSwipe.activateInstance: Unable to active instance as another instance is already active for this target"

(function(window, Util, PhotoSwipe){
    $(document).ready(function(){

        $('#home').live('pageshow', function(e){    

                var 
                currentPage = $(e.target),
                homeSlider;
                homeSlider = PhotoSwipe.attach(
                window.document.querySelectorAll('#slider a'),
                {
                    target: window.document.querySelectorAll('#PhotoSwipeTarget')[0],
                    loop: true,
                    preventHide: true,
                    autoStartSlideshow: true,
                    captionAndToolbarHide: true,
                    margin: 0,
                }
                ); // PhotoSwipe.attach         
                homeSlider.show(0);     
                return true;    

            });
            $('#home').live('pagehide', function(e){

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

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

                return true;

            }); 

        }); // $(document).ready(function(e){
    }(window, window.Code.Util, window.Code.PhotoSwipe)); // function(window, util, PhotoSwipe)
nate8684
  • 539
  • 1
  • 9
  • 27

0 Answers0