Comments (18)
Hi,
latest fancyBox version 2.1.2 and turbolinks are working fine. Unfortunately fancyBox from version 2.0 is not free for commercial use anymore.
I'm closing the issue as probably the problem is on the fancyBox side...
from turbolinks-classic.
For those wondering how to get fancybox 1.3.4 working with turbolinks (because I didn't want to update my fancybox.) :
Call $.fancybox.init()
on page:change
Update this line in the fancybox js file (function is _start, approx. line 76 on the non minified version):
selectedOpts = $.extend({}, $.fn.fancybox.defaults, (typeof $(obj).data('fancybox') == 'undefined' ? selectedOpts : $(obj).data('fancybox')));
to
currentOpts = selectedOpts = $.extend({}, $.fn.fancybox.defaults, (typeof $(obj).data('fancybox') == 'undefined' ? selectedOpts : $(obj).data('fancybox')));
This seemed to fix all my problems :)
from turbolinks-classic.
I've been able to use it without changing the fancybox.js file. Only with:
$(window).bind('page:change', function() {
$.fancybox.init();
});
Thanks R-osey! :)
from turbolinks-classic.
Cool!
Thanks for your help @jd-erreape and @R-osey!
Marek
from turbolinks-classic.
It doesnt work for me (v. 2.1.5)
i made this hack to make it work
// turbolinks vs fancybox bug
$galleryHolder = $('<div id="gallery_holder"></div>').appendTo(document.body);
$('.gallery').fancybox({
parent: $galleryHolder,
openEffect: 'none',
closeEffect: 'none'
});
I guess something is cached wrong inside fancyBox.
from turbolinks-classic.
@antpaw thank you for this, I had this issue on iOS only, your code fixed it! Did you had the problem also on desktop or mobile only like me?
from turbolinks-classic.
@antpaw any idea why the parent attribute fix it?
from turbolinks-classic.
@allaire i think the part where the "parent" elem is cached in the fancyBox is broken because they dont let go of it after it was removed from the dom, pretty sure this is not a turbolink issue
from turbolinks-classic.
@antpaw Thanks for the additional info. It's still weird tho, since the parent is not truly the parent of the lightbox stack in the DOM (see https://cloudup.com/cBATDstodGb)
from turbolinks-classic.
@allaire no i think thats okay, the holder contains only the big images that you see when you click on the thumbs, im sure this element will get some children once you click
from turbolinks-classic.
@antpaw nothing change when I click, the container does not get any child elements, but I guess that's ok, as long as it fixes the issue :)
from turbolinks-classic.
@antpaw it works for me, thanks
from turbolinks-classic.
@antpaw thank you too. This problem is still relevant for v2.1.5 as it's the latest version.
from turbolinks-classic.
it still has some bugs after the popstate event (whenever you use the back button) :(
hope they stop caching $('body') soon
from turbolinks-classic.
Thank you @jd-erreape!
from turbolinks-classic.
Thank you @antpaw.
Working fine for me. I am using fancybox version 2.1.5
But I suggest you to use:
// turbolinks vs fancybox bug
var $galleryHolder = $('#gallery_holder');
if ($galleryHolder.length === 0) {
$galleryHolder = $('<div id="gallery_holder"></div>').appendTo(document.body);
}
$('.gallery').fancybox({
parent: $galleryHolder,
openEffect: 'none',
closeEffect: 'none'
});
from turbolinks-classic.
The solutions mentioned by @iceless58 and @antpaw not working for me.
Using Fancybox2-Rails
(Fancybox 2.1.5
) with Ruby 2.2.0
, Rails 4.2.0
and Turbolinks 2.5.3
. (cc: @Kyparn)
from turbolinks-classic.
This won"t work when using it programatically with $.fancybox.open
from turbolinks-classic.
Related Issues (20)
- Page does not always scroll to the top when DOM loads too fast
- SVG anchors not working with turbolinks
- Turbolinks.visit, partial replacement & relative urls (& IE11)
- Not correctly inferring protocol with SSL, unless force_ssl is set HOT 2
- Redirect and reload full page HOT 1
- JavaScript part of turbolinks on npm HOT 11
- Enable Turbolinks on a-tags after adding content over AJAX HOT 1
- File type blacklist instead of whitelist
- Scroll position of data-turbolinks-permanent elements lost on navigation. HOT 3
- Webpage without title, after turbolink has title of undefined HOT 1
- Problems with JS HOT 1
- Rails 5 deprecations
- Would you please tell me how to add your library or whether it's necessary to add this library?
- Sorry for duplicate
- Progress bar causing capybara tests to fail
- Documentation does not explain how to install current turbolinks-classic version HOT 1
- temporary inside permanent
- Clicking browser back button from an error page to a non-error page, retains the styles of the error page
- Turbolinks.enableProgressBar() returns undefined
- How to binding "page:load" cache-preview
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from turbolinks-classic.