Adding elements to a grid/gallery using AJAX
OK, so not really a laravel question and more general, but here is my situation that I am looking for advice on. I have a page with a gallery and a dropzone to add more items to the gallery. When the images are uploaded I would like to add them to the gallery using JS. The problem I am facing is that when I first load the page I have the nifty laravel Chunk feature to lay the images out in the appropriate grid, with rows interspaced where required, but it isnt so easy in js.
The way I see it I have a couple of options:
- reload the entire gallery component on each upload so I can re-use the chunk feature
- write some js which identifies the number of children of the last row element and if it is equal to X then add a new row div and insert the new image into that
Is there a third option that I am missing that is easier than those two? Ideally if I could put all of the images in a single row div and have them wrap nicely as required to fit the screen width that would make things a lot easier.
Please or to participate in this conversation.