Closed stathimexas closed 2 years ago
Hi, Replace
$.fancybox({ title: "some title", autoCenter: true, content: "<div ><p>some message</p></div>" });
with
Fancybox.show([{type: "html", src: "<div ><p>some message</p></div>", caption: "some title"}]);
Hi. I tried this solution but it does not create the popup, as if it is ignored. I am using Fancybox4, by the way. Is there anything else I have to do to trigger it? Does it need to go to the
section? Please help me. Thank you.Look, the snipped I gave you previously works perfectly fine, the rest is up to you - you have to decide when and how to use it in your own code. If you are using PHP, then you have to have some basic knowledge of programming and debugging your code. Do you know what HTML entities are and what https://www.php.net/manual/en/function.htmlspecialchars.php and https://www.php.net/manual/en/function.htmlentities.php are used for?
Ok Jānis. I will work on it more. Thank you. I have some knowledge of both PHP and debugging. If you know how to make this snippet work for me though, I would appreciate it. I have spent hours trying to implement it.
There is nothing special about it, if you put it between <script>
tags and fancybox js file is loaded correctly, then it will run as expected. I really do not know what to add... If you could provide a link to your page, I could quickly tell where is the problem.
I got it to work. Thank you so much for your help. You are always very nice and helpful.
Well, thanks. Sorry, but you could you tell what what the cause of the issue? Could the docs be improved to avoid similar situations to others?
It will work after you fix these issues on your page:
Uncaught TypeError: Cannot read properties of undefined (reading 'style')
at showDivs ((index):278)
at (index):270
(index):468 Uncaught ReferenceError: janis is not defined
at (index):468
(index):469 Uncaught ReferenceError: Fancybox is not defined
at (index):469
Please, learn to debug your code. You can press F12 to open developer tools (in any browser) and Console tab will reveal any issue. Any JavaScript error can prevent further execution of the JavaScript.
Jānis, thank you so much for your kind help. I apologize for not being thorough enough.
How do I implement this popup for fancybox4 on PHP?
echo '<script>$.fancybox({ title: "some title", autoCenter: true, content: "<div ><p>some message</p></div>" });</script>';
Thank you.