2010-06-25 2 views
0

jQuery로드 함수를 사용하여 이미지를 외부 적으로로드하고 있지만 라이트 박스를 추가 할 수 없습니다 ..jquery에서 외부에로드 된 이미지에 라이트 박스를 추가하는 방법은 무엇입니까?

매우 새로운 jquery입니다.

var href = $('#images').attr('href'); 

$('#images').click(function(){ 
    var toLoad = $(this).attr('href')+' #content'; 

    $('#content').hide('fast',loadContent); 
    $('#load').remove();   
    $('#wrapper').append('<span id="load">LOADING...</span>'); 
    $('#load').fadeIn('normal');   
    window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-3);  

    function loadContent() { 
     $('#content').load(toLoad,'',showNewContent()); 

    } 
    function showNewContent() { 
     $('#content').show('normal',hideLoader()); 
    } 
    function hideLoader() { 
     $('#load').fadeOut('normal'); 
    } 
    return false; 
}); 

이 함수는 $ (document) .ready()에 있으며 동적로드 된 이미지가 라이트 박스의 일부가되도록 아래 함수를 추가해야합니다. 뭐하는 거지

$('.gallery a').lightBox({txtImage: 'Design'}) 

는 파일 portfolio.php을 호출하고 #content div의 내부 HTML을 복용하고 사용자가보고있는 페이지에서 #content div의에 넣기 ...입니다.

가능하면 코드를 도와주세요.

답변

1

여기서는 .gallery이 (가) #content의 하위라고 가정합니다. 이처럼 showNewContent() 함수에 추가합니다 :

function loadContent() { 
    $('#content').load(toLoad,'',showNewContent); 

} 
function showNewContent() { 
    $('#content').find('.gallery a').lightBox({txtImage: 'Design'}) 
       .end().show('normal',hideLoader); 
} 
function hideLoader() { 
    $('#load').fadeOut('normal'); 
} 

콜백하지 showNewContent() (! 어떤 괄호)로 showNewContent를 호출해야합니다, 그렇지 않으면 그것은 실제로 바로 그 기능을 실행하고를 할당하려고 결과는이며, 함수 자체는 콜백되지 않으므로 애니메이션이 완료 될 때 실행되지 않습니다.

+0

감사합니다. Nick ... it worked! – Masade

관련 문제