-
Notifications
You must be signed in to change notification settings - Fork 22
Lightbox fails to attach event handler to elements and also fails to work at all #9
Comments
I have no idea why it doesn't work in some cases, because I have a rails project with lightbox2-rails already and it works just out of the box, but anyway there is one point about lightbox – it's required to be load after page is loaded. I found some ugly way (but it works, so anyway) to put lightbox script in Usually we put
Next, we create another manifest file footer.js for scripts which we want to load in
Next step, edit layout file ( And after all, we need to precompile new manifest file:
|
This may be in reference to a prior issue. I forked another repo that had the fix and it's been working for me. |
@JakeTheSnake3p0 thanks! Your fix worked for me too |
How about a pull request? |
@mvz Merged, Thanks Mat |
Just tested the patch and I can confirm that it works. |
@gavinkflam As the fix is already merged, could you release a new gem version? |
Any eta for a new release? |
Obvious. $(document).on('turbolinks:load', function(event) {
lightbox.init();
}); Should be in README. |
Could not get working - switched to updated gem here: https://github.com/johansmitsnl/lightbox2-rails (Thanks to johansmitsni for updating & saving to having to debug issue) |
The JS file is included in the head and apparently that results in the event 'click' handler not being applied to the element. When I put
//= require lightbox
in its own JS file and included it near the bottom of the<body>
tag the event handler was successfully attached.However it still didn't help anything as the link still navigates directly to the image and doesn't stay on the page and load the lightbox.
My link has
data-lightbox="weddings"
attribute. Also for what its worth, the JS console reads (in Google Chrome):Resource interpreted as Document but transferred with MIME type image/jpeg: "[image URL]".
I'm using jQuery v2.2.1 (using jquery-rails and
//= require jquery2
inside of application.js)The text was updated successfully, but these errors were encountered: