Answer the question
In order to leave comments, you need to log in
Does json have the right to live in the data- attribute?
I would like to hear the opinion of the community.
In short: what do you think about storing in json's data attributes?
In more detail, below I describe how I got to this point: I am making
a portfolio website.
Tile of thumbnails-photos (photo shoots), on hover - the name and name of the photographer.
On click - a modal with a photo frame of photos, title, photographer's name, description, list of tags.
The thumbnail is taken from the first photo of the array (ACF Gallery field), some of the information is duplicated...
And in general, I thought that when opening a modal, it makes no sense to pull the base with an ajax request (and given that portfolio pages can be cached - not at all).
Well, I did this:
All the information I need to open the modal, converted to json, is in the data attribute. Click - and now the rendered modal.
I understand that you can stuff all this into a variable, which js will access when opening the modal, but there are difficulties with pagination, instead of loading via ajax.
Answer the question
In order to leave comments, you need to log in
I think it's not so bad when there is little information, but when it's like yours, you need to come up with something else.
Try to create an object in js with all the data and write only id to the tag and then search in the object by id.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question