FancyBox 'Uncaught TypeError: Cannot call' hide 'method from undefined'

I cheated on fancybox. I work in CakePHP Framework and I created an admin panel. This panel has several options that I upload via AJAX to the Div above the page itself.

Now, when I put the image in this div and try to use Fancybox, I get this error when I click on the image (to enlarge it):

Uncaught TypeError: Cannot call method 'hide' of undefined N I b.fn.fancybox f.event.dispatch f.event.add.h.handle.i 

Now this is my ajax loader (functions.js)

 $(".cmsPage").click(function() { var url = $(this).attr("href"); $.ajax({ url: url, success: function(data){ $("#admin_wrapper").fadeIn('slow'); $("#admin_content").fadeIn('slow'); $("#admin_close").fadeIn('slow'); $("#admin_content").html(data); } }); return false; }); 

admin_content is where the images are displayed:

 #admin_content{ display:none; position:absolute; z-index:10; background-color:#fff; opacity:1; width:1000px; min-height:500px; top:1%; color:black; padding:10px; margin:10px; border:solid black 1px; border-radius:5px; } 

But if I go to the page (without using ajax), it works fine.

Is there something that fancybox overloads? The error is not so clear to me. I tried everything here. But I do not use wordpress.

+4
source share
3 answers

I ran into this same error because I recklessly included jquery.fancybox.js twice on the page. Just delete the second call and the problem should be fixed.

+14
source

I had the same problem and the problem was that fancybox was invalid several times. You just had to make sure to do it later.

0
source

I am having this problem with me. The problem was that I saved the jsFiddle source code that I was working on to test it in a server sandbox environment. When fancyBox (1.3.4) is initialized by jsFiddle, it created a lot of hidden divs and is thus related to how the lightbox is created. As soon as I noticed this and removed all these additional <divs> from the source code, it worked fine.

0
source

Source: https://habr.com/ru/post/1411726/


All Articles