Program Tip

열린 'fancybox'내에서 함수에서 멋진 상자를 닫습니다.

programtip 2020. 12. 2. 21:44
반응형

열린 'fancybox'내에서 함수에서 멋진 상자를 닫습니다.


안녕 모두 내에서 열릴 때 fancyBox를 닫을 수 있기를 바랍니다.

다음을 시도했지만 아무 소용이 없습니다.

function closeFancyBox(html){
    var re = /.*Element insert complete!.*/gi;
    if( html.search( re ) == 0 ){
        $.fancybox.close();
        //alert("foo");
    }
}

foo는 대화 상자에서 열리지 만 닫히지는 않습니다. 힌트가 있습니까?


이것을 시도하십시오 : parent. $. fancybox.close ();

Fancybox API 문서를 참조하십시오 .


http://fancybox.net/faq 에 따르면

  1. 다른 요소에서 FancyBox를 어떻게 닫을 수 있습니까? ?

$.fn.fancybox.close()onClick 이벤트를 호출 하십시오.

따라서 fn.


멋진 상자를 닫고 싶다면 닫는 것으로 충분합니다.

$('#inline').click(function(){
  $.fancybox.close();
});

fn을 넣는 것은 소용이 없으며 프로토 타입과 관련이 있습니다.
해야 할 일은 $ .fancybox.close ();

문제는 js에서 다른 오류가 발생할 수 있다는 것입니다.
화면에 오류가 있습니까?
fancybox와 jquery가 최신 릴리스입니까? jquery는 현재 1.4.1에 있고 fb는 1.3에 있습니다.

fancybox 안에 링크를 넣어 실험하고 그 함수를 넣어보세요.

당신은 아마 그것을 읽었을 것입니다. 그러나 어쨌든, http://fancybox.net/api

아마도 당신이해야 할 한 가지는 그것이 무엇인지 깨닫기 위해 각 부분을 분리하는 것입니다.


닫기 버튼 ID를 얻고 해당 ID에 대한 클릭 이벤트를 호출하여 fancybox를 닫을 수도 있습니다.

<input type='button' value='Cancel' onclick='javascript:document.getElementById("fancybox-close").click();' />

그것은 나를 위해 작동합니다!


나는 오랫동안 같은 문제를 겪었고 아래 코드로 해결책을 얻었습니다. 사용하시기 바랍니다

parent.jQuery.fancybox.close()

오래된 실이지만 ...

실제로 창 에서 창 을 닫는 방법에 대한 원래 질문에 대한 대답 은 클릭 이벤트가 요소에 첨부되지 않는다는 사실과 더 관련이 있다고 생각합니다. document.ready에 click 이벤트가 첨부되어 있으면 fancybox가 새 창을 생성 할 때 해당 이벤트가 첨부되지 않습니다.

새 창이 나타나면 클릭 이벤트를 다시 적용해야합니다. 이 작업을 수행하는 가장 쉬운 방법은 onComplete 기능을 사용하는 것입니다.

이것은 나를 위해 작동합니다.

$(".popup").fancybox({
    'transitionIn'  :   'fade',
    'transitionOut' :   'elastic',
    'speedIn'       :   600, 
    'speedOut'      :   400, 
    'overlayShow'   :   true,
    'overlayColor'  :   '#000022',
            'overlayOpacity'  : 0.8,
            'onComplete' : function(){$('.closer').click(function(){parent.$.fancybox.close();})}
});

사실, '클릭'이나 '바인딩'보다는 '라이브'를 약간 생각한 후에도 잘 작동 할 수 있습니다.


대신 이것을 사용하여 닫으십시오.

$.fn.fancybox.close();

fancybox 소스 코드로 판단 할 때 내부적으로 닫는 방식을 사용합니다.


After struggling myself with this I found a solution that works just replace the $ with jQueryjQuery.fancybox.close() and I made it an inline script on an onClick. Going to check if i can call it from the parent


For those who spent hours like me to find out the solution for inline type: window.setTimeout(function(){$.fancybox.close()},10);


I ended up using:

<script>parent.$("#fancy_close").click();</script>

I guess the version of fancybox we have doesn't have a $.fancybox.close() function for me to call :(

FYI, I just wanted the page to close the fancybox, as it had finished its processing in PHP.


Add $.fancybox.close() to where ever you want it to be trigged, in a function or a callback, end of an ajax call!

Woohoo.


Within an iframe use - parent.$.fancybox.close();


to close fancybox by funciton its necessary to make setTimtout to the function that will close the fancybox Fancybox needs some time to acept the close function If you call the function directly will not work

function close_fancybox(){
$.fancybox.close();
                     }
setTimeout(close_fancybox, 50);

yes in Virtuemart its must be button CLOSe-continue shopping, not element, because after click you can redirect.. i found this redirect bug on my ajax website.


To close ajax fancybox window, use this:

onclick event -> $.fancybox.close();
return false;  

참고URL : https://stackoverflow.com/questions/1829319/close-fancy-box-from-function-from-within-open-fancybox

반응형