Im stuck with a little problem with fancyBox v2.
I want to launch fancyBox on button click. Once clicked, it will load all the images from the list (from the src attribute of the ).
I have created this jsfiddle to show what I am trying to do: http://jsfiddle.net/fPFZg/
jQuery(document).ready(function($) {
$('button').on('click', function() {
$.fancybox();
});
});
Can anybody see how this would be possible?
Once clicked, it will load all the images from the list (from the src attribute of the ). jQuery(document). ready(function($) { $('button'). on('click', function() { $.
Here is the code: if ($('div#fancybox-frame:empty'). length >0) { alert('it is empty'); $.
fancybox is designed to display images, video, iframes and any HTML content. For your convenience, there is a built in support for inline content and ajax. Images.
I had the same question and found the following to be a simpler method:
<button class="fancybox" value="Open Fancybox">Open Fancybox</button>
<div class="hidden" id="fancybox-popup-form">
(your Fancybox content goes in here)
</div>
$('.fancybox').click(function () {
$.fancybox([
{ href : '#fancybox-popup-form' }
]);
});
.hidden { display: none; }
Fancybox Docs (click the "API Methods" tab, then read up on the first method, which is called "Open").
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With