2011-11-03 4 views
1

$ .fancybox.close() 함수에서 매개 변수를 전달하고 OnClosed 이벤트에서 해당 매개 변수를 읽는 방법이 있습니까? 이 같은fancybox 닫기 함수에서 매개 변수 전달

뭔가 :

$("#id_div").fancybox({ 
     'width': '40%', 
     'height': '40%', 
     'autoScale': false, 
     'transitionIn': 'none', 
     'transitionOut': 'none', 
     'type': 'iframe', 
     'onClosed': function (parameter) { 
     alert(parameter);} 
    }); 

$.fancybox.close("parameter") 

답변

1

아니,하지만 당신은 변수와 같은 일을 달성 할 수있다.

당신이 $(document).ready() 내부 코드를 포장하는 경우

,이 같은 무언가 작동합니다 :

$(function(){ 
    var closedParam; 

    $("#id_div").fancybox({ 
     'width': '40%', 
     'height': '40%', 
     'autoScale': false, 
     'transitionIn': 'none', 
     'transitionOut': 'none', 
     'type': 'iframe', 
     'onClosed': function (currentArray, currentIndex, currentOpts) { 
      // Use closedParam here 
     } 
    }); 

    // In some other function 
    closedParam = ... ; 
    $.fancybox.close(); 
}); 
+0

동일한 범위 내에서 함수 (.close() 및 fancybox())를 가지고 있지 않아 전역 변수를 만들고 싶지 않습니다. – Sampat

+0

그렇다면 아니오, fancybox 플러그인 코드를 수정하는 방법은 없습니다. – rossipedia

0

당신이 전역 변수는 숨겨진 여부를 DOM 객체의 속성을 사용하여 사용하지 마십시오.