fancyapps / fancybox

jQuery lightbox script for displaying images, videos and more. Touch enabled, responsive and fully customizable.
http://fancyapps.com/
7.28k stars 1.78k forks source link

ajax modal window problem with scripts #1841

Closed egorkhu closed 6 years ago

egorkhu commented 6 years ago

Hello)

At the bottom of my main page – index.html i have to lines of code with libraries for animation:

<script src='js/tweenMax.min.js'></script>
<script src='js/DrawSVGPlugin.min.js'></script>

Also on this page i have a button which call ajax modal window:

<a class="button2" data-fancybox data-type="ajax" data-src="contact.html" href="javascript:;">

This is how my contact.html inside looks like:

<div>
     <script>
          using different operators from libraries for animation
     </script>
     <div>
        ....
     </div>
</div>

The problem is that in version 3.1.28 code in script tag works perfect, but in 3.2.10 code in my modal window don't work.

Working example – egorlero.com Don't working example – egorlero.com/exp

Just click small green button "Хочу" at the welcome screen and see the difference)

Thx for your answer!

fancyapps commented 6 years ago

Hi,

Maybe try to move <script> tags to the end of the file.

egorkhu commented 6 years ago

No, it don't work :(

fancyapps commented 6 years ago

Sorry, I have no other idea, your inline JS code is executing, so, try to debug it.

btw, I do not understand what issue you are having. Do you really use tweenMax just to scale SVG icon? Why don't you use CSS for that? Your JS simply adds transform: matrix(3, 0, 0, 3, 0, 0)

egorkhu commented 6 years ago

It's a whole animation of button when succeed)) Morphing, svg drawing and etc!

When I use files of previous version of Fancybox with the same inline JS code all works fine, but on the new version it don't get my tweenmax library, that is why no animation and etc.)

fancyapps commented 6 years ago

I do not know if you have changed something lately, but, right now, you do not have TweenLite in your 2nd page - Uncaught ReferenceError: TweenLite is not defined

egorkhu commented 6 years ago

Yep! I changed a code a little bit, merged a couple of files (tweenmax, drawsvg, morphsvg) in one file - jquery1.10....js, and add it in the head)

egorkhu commented 6 years ago

The same error was when I added all files separately at the bottom of document)

egorkhu commented 6 years ago

Also at the booth of the site I have the same form, with the same code, be free to test it if u want)

fancyapps commented 6 years ago

Your issue is not related to fancyBox at all. You have Uncaught ReferenceError: TimelineMax is not defined error on your page. And, like I said, TweenLite is undefined, therefore you can not expect it to work.

egorkhu commented 6 years ago

Ok, I will check all code carefully)

Thx a lot, sorry for spent your time)

egorkhu commented 6 years ago

I found the difference between to versions! In the previous version 'fancybox-container' created after tag, at the beginning of page, but in last version it create 'fancybox-container' at he end of page.

egorkhu commented 6 years ago

I check my code, and it's correct)

fancyapps commented 6 years ago

If your code would be correct, then it would not matter where container is located, don't you think so?

egorkhu commented 6 years ago

Maybe yes or maybe not, when I change 'Container is injected into this element' from 'body' to 'header' which i create at the beginning of the page, all works perfect, because it create 'fancybox-modal' before external libraries) So i fix this problem for me! Thx a lot)