Append content dynamic with Json
See original GitHub issueHi,
I’m trying to append content dynamically from a Json file but I cannot find a work around to make it work.
import Glide from '@glidejs/glide';
function slider() {
let ul = document.querySelector('.glide__slides');
let card = '';
var glide = new Glide('.glide').destroy();
const photo = import('../metadata/photos.json').then((module) => {
const data = module.default;
data.forEach((photo) => {
console.log(photo);
card += `<li class="glide__slide"><img src="${photo.thumbnailUrl}" alt="${photo.title}">${photo.id}</li>`;
});
ul.innerHTML = card;
});
glide.mount();
}
slider();
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
How to add data dynamically in JSON object - Stack Overflow
Easy: oldJsonObj.vector = [] //this creates a new element into the object foreach(dataTable.getNumberOfRows()){ var x = {} x.id = XXX; ...
Read more >Dynamic JSON - Retool Docs
Here are some examples of expressions that work (click on the JSON tab to see the evaluation): Normal ES5 ... Dynamically adding properties...
Read more >Fetch data dynamically - Dart programming language
JSON is text based and human readable. The dart:convert library provides support for JSON. Use HttpRequest to dynamically load data. Web apps often...
Read more >Append Json Files from a list of dynamic URLS
Append Json Files from a list of dynamic URLS. 12-02-2020 03:51 AM. Is this possible? The structure of the Json files are consistent....
Read more >Creating and Modifying Dynamic Entities | Using JSON
The %FromJSON() method converts a JSON string to a dynamic entity. The following example constructs a dynamic array and serializes it to string...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Looks like youre inserting dynamic content through an event listener but mounting glide outside of it. You need to mount glide after each time, but its more complicated - on each change, destroy previous glide, insert content, then construct a new glide and then mount. You need to do that last part because destroy and mount aren’t opposites, once youve destroyed mount wont reinit event listeners etc.
On Mon, Sep 7, 2020, 12:09 PM Nicolas Deyros, notifications@github.com wrote:
I thinks I resolve the issue thank to you @albanyacademy doing this: