instatiate lightbox only when needed, slight hack
This commit is contained in:
parent
7478c36108
commit
5ceaff890f
@ -1,4 +1,10 @@
|
|||||||
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
|
// Configure your import map in config/importmap.rb.
|
||||||
import GLightbox from 'glightbox';
|
// Read more: https://github.com/rails/importmap-rails
|
||||||
|
|
||||||
const lightbox = GLightbox({ });
|
// Currently haml filter does not support modules.
|
||||||
|
// import and make global as workaround
|
||||||
|
//
|
||||||
|
// haml module syntax is really clunky, filing issue and hoping
|
||||||
|
//
|
||||||
|
import GLightbox from 'glightbox';
|
||||||
|
globalThis.GLightbox = GLightbox;
|
||||||
|
@ -47,3 +47,7 @@
|
|||||||
= link_to edit_picture_path(picture) do
|
= link_to edit_picture_path(picture) do
|
||||||
%button.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400
|
%button.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400
|
||||||
Edit Picture
|
Edit Picture
|
||||||
|
:javascript
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
const lightbox = GLightbox({ });
|
||||||
|
});
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
.mx-20.grid.grid-cols-1.md:grid-cols-2.lg:grid-cols-3.2xl:grid-cols-4.gap-8.md:gap-12.lg:gap-16
|
.mx-20.grid.grid-cols-1.md:grid-cols-2.lg:grid-cols-3.2xl:grid-cols-4.gap-8.md:gap-12.lg:gap-16
|
||||||
- Picture.all.limit(4).each do |picture|
|
- Picture.all.limit(4).each do |picture|
|
||||||
= render "pictures/picture" , picture: picture
|
= render "pictures/picture" , picture: picture
|
||||||
|
|
||||||
|
:javascript
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
const lightbox = GLightbox({ });
|
||||||
|
});
|
||||||
|
@ -16,3 +16,6 @@
|
|||||||
New Picture
|
New Picture
|
||||||
|
|
||||||
:javascript
|
:javascript
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
const lightbox = GLightbox({ });
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user