2011-12-13 4 views
0

Im 이미지 갤러리를 만드는 데 AdGallery를 사용합니다 (이 플러그인 다음 : http://coffeescripter.com/2009/07/ad-gallery-a-jquery-gallery-plugin/). 큰 이미지를 사용자가 클릭이 라이트 박스가 나타납니다Jarrie 라이트 박스가 AdGallery와 작동하지 않습니다.

http://leandrovieira.com/projects/jquery/lightbox/ 지금 내가이 원하는 :

그리고 jQuery를 라이트 박스

.

if(image.link) { 
      var link = $('<a rel="lightbox" href="'+ image.link +'" target="_blank"></a>'); 
      link.append(img); 
      img_container.append(link); 
     } else { 
     var link = $('<a href="'+ image.image +'" rel="lightbox" class="lightbox"></a>'); 
     link.append(img); 
      img_container.append(link); 
     } 

if(image.link) { 
      var link = $('<a rel="lightbox" href="'+ image.link +'" target="_blank"></a>'); 
      link.append(img); 
      img_container.append(link); 
     } else { 
     img_container.append(img); 
     } 

에서

하지만 큰 이미지를 클릭하면, 아무 일도하지 : 그래서 jquery.ad-gallery.js에 몇 줄의 코드를 수정했습니다. 내가 여기서 무엇을

$(function() { 
    $('#gallery a').lightBox(); 
}); 

누락되었습니다

나는 나의 HTML에서이 코드를했다?

답변

4

대신 :

$(function() { 
$('#gallery a').lightBox(); 
}); 

사용 :

$(function() { 
$('a.lightbox').each(function() { $(this).lightBox(); }); 
}); 

이 이상한 결과 사업부에 다른 그래픽에 '다음'옵션을 보여주는에서 라이트 박스를 방지하고 부착하기에서 라이트 박스 방지 미리보기 이미지.

당신은 또한 _showWhenLoaded의 끝에서

$('a.lightbox').each(function() { $(this).lightBox(); }); 

를 추가, 이미지를 변경하면 광고 갤러리 광고 이미지 DIV의 내용을 플러시 때문에 : 기능을 jquery.ad-gallery.js에 lighbox 이벤트 있도록 선택한 각 이미지에 첨부됩니다.

2

나는 큰 어려움을 겪고있다.

슬라이드 쇼의 주 이미지가 큰 라이트 박스 팝업으로 나타나는 것이 좋습니다. 해결하기

이슈는 다음과 같습니다

라이트는 기존의 요소를 검색하고 이미지의 배열을 만들지 만, 여기에 우리가 한 번에 작업 할 수있는 하나 개의 동적 항목이있다. 라이트 박스에서 찾을 동적 요소는 동적이므로 기본 메서드가 아닌 동적 jQuery 메서드를 사용해야합니다. Lightbox가 하나의 메인 이미지 만 찾을지라도 슬라이드 쇼의 모든 이미지를 알기를 원합니다. 라이트 박스가 이미지와 관련된 텍스트를 찾길 원합니다.

해결하려면

당신이 엄지 손가락의의 longdesc 속성에 큰 팝업의 경로를 넣어 있는지 확인하십시오, 그런 식으로 광고 갤러리 슬라이드 이미지 주변의 href 속성에 넣어, 그리고 라이트 박스 것이다 것 그들을 찾으십시오

광고 갤러리에 콜백을 사용하여 모든 슬라이드에 라이트 박스로드를 호출하십시오.

http://www.vikingkayaks.co.nz/shop/kayaks?product=1

을하지만,이 예에서는 다른 복잡한 일들이 있습니다주의, 그래서 나는 위의 설명에서 중요한 부분을 증류하는 것을 시도했다 :

 $(function() { 

      gallery1 = $('#gallery1').adGallery( 

         { 
          callbacks: 
           {afterImageVisible: 
            function(){ 

       //lightBox loading stuff here 

       dynamically find the title text and put it into the title of the link so lightBox can use it 
       if(this.images[ this.current_index ].title) 
       { 
         $(document).find('.ad-image a').attr('title', this.images[ this.current_index ].title); 
       } 

       //use jQuery find to get the dynamic element then apply lightBox to it 
       $(document).find('#gallery1 .ad-image a').lightBox({ imageArray: aImagesFullSizeLightBox, fixedNavigation: true }); 

       //note, the "imageArray: aImagesFullSizeLightBox". This was my code addition to lightBox, which allowed me to tell lightBox what the imageArray is rather than trying to find them itself. You need to construct this array beforehand (see example below) in the correct format for lightBox to use, and you need to make code changes to lightBox to tell it to use it. 



              } 
          } 
         }); 

    } 

/////////////////////////////////////////////////////////////////////////////// 

//example array to pass to lightBox, make sure the above function can see it 

var aImagesFullSizeLightBox = []; 

aImagesFullSizeLightBox.push(new Array('/images/bigPopupImage1.jpg','The Title Here 1')); 

aImagesFullSizeLightBox.push(new Array('/images/bigPopupImage2.jpg','The Title Here 2')); 


////////////////////////////////////////////////////////////////////////////////////// 

//code changes needed to lightBox (this was done to version 0.5 which may be old now!) 

$.fn.lightBox = function(settings) { 

     //addition to support next and backs without lightbox taking control of clicks on thumbs 3/6/2012 Gordon Rouse 
     if(settings.imageArray) 
      settings.setImagesExternally = true; 
     else 
      settings.setImagesExternally = false; 

/////ALSO//////////////////////////////////////////////////////////// 


function _start(objClicked,jQueryMatchedObj) { 

      $('embed, object, select').css({ 'visibility' : 'hidden' }); 

      _set_interface(); 

      // Unset total images in imageArray 
      //addition to support next and backs without lightbox taking control of clicks on thumbs - Gordon Rouse 
      if (!settings.setImagesExternally) 
       settings.imageArray.length = 0; 

      //settings.imageArray.length = 0; //undo line for above! 

      settings.activeImage = 0; 

         //here we stop lighBox trying to load the images it found 
      if (!settings.setImagesExternally) 
      { 
       if (jQueryMatchedObj.length == 1) { 
        settings.imageArray.push(new Array(objClicked.getAttribute('href'),objClicked.getAttribute('title'))); 
       } else { 
        // Add an Array (as many as we have), with href and title atributes, inside the Array that storage the images references   
        for (var i = 0; i < jQueryMatchedObj.length; i++) { 
         settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute('href'),jQueryMatchedObj[i].getAttribute('title'))); 
        } 
       } 
      } 

/////////////////////////////////////////////////////// 

이 작업의 예

여기에서 찾을 수 있습니다.

관련 문제