Custom widget - link value for modal

I have a custom widget that works fine. It reads data from a custom table and displays 10 results in a widget area.

I store additional data from the query that gets the results in an array.

I want to turn each of the results that are displayed in the widget into a link that opens a modal window with the additional data.

I have the link working and the modal (CSS only) working fine.

The issue I have is how do I pass the array value, depending on which of the 10 links is clicked, to the modal code so that the correct data is displayed.

I presume I need to use data-* in the url coding and jquery to read it into the php code to display the correct array. I have spent a couple of days searching with Google but have been unable to find an easy way to do this that I can understand.

Any suggestions most welcome.

Well, without knowing your code and noting you mentioned data-*, you might be using Bootstrap.
Passing data to a modal is fairly simple enough. Normally not an array. Since your data is 10 links,
you can use multiple items listed as hidden links and select the active ones to send to the modal.
Here is a page that discusses it in several different ways. Hope it helps. SO-passing-to-modal

Thanks for the reply I hadn’t found that one in my search. I am not using bootstrap data-* is standard in HTML5 the asterisk being replaced with a word that you use as reference elsewhere such as id.

Well, perhaps you should just create a test page with the minimum code needed and show us what you have and then we could help better. It’s easy seeing the code…

Sponsor our Newsletter | Privacy Policy | Terms of Service