2011-03-18 4 views
0

jquery 플러그인의 기존 함수에 콜백을 추가하려고합니다. https://github.com/premasagar/nitelite - 콜백에 ajax가 없으면 콜백은 http://jsfiddle.net/HPc4e/2/으로 작동합니다. 가까운 기능의아약스가 포함 된 콜백 실패

해당 섹션 :

// Blah blah ... 

else { 

    showFlash(); 

    this.overlay.remove(); 

    this.container 
     .empty() 
     .remove(); 

    $(this).triggerHandler('close'); 

    // Add callback 
    if (typeof callback == "function") { 
     callback(); 
    } 

} 
return this; 

콜백 :

lb.close(undefined, 'click', function() { 
    $.ajax({ 
     type: 'POST', 
     url: url, 
     data: {submit: $(this).val()}, 
     dataType: 'json', 
     success: function(data) { 
      lightbox('Lightbox 2', '<p>Oh hi</p>', 'lightbox2'); 
     } 
    }); 
}); 

감사

+0

동작을 보여주는 데모 (jsfiddle.net?)를 사용할 수 있습니까? .empty 및 .remove는 DOM이 업데이트 될 때까지 반환되지 않아야합니다. – Alnitak

+0

물론 몇 분만 기다려주세요! –

+0

오, 쓰레기 내 작품을 작동합니다 :/http://jsfiddle.net/HPc4e/2/ –

답변

0

내가 콜백 예외를 던지고있다 용의자.

this이 호출 될 때의 값은 무엇입니까? .val() 메서드가있는 jQuery 호환 요소를 가리키고 있습니까?

+0

어쩌면 -하지만 데이터'{제출 : $ (this) .val()} '을 제거해도 효과가 없습니다. –

+0

URL에 예외가 발생했습니다. 감사 –

관련 문제