I have a div popup script which works as intended - see working version here. I wish to use this code within a php loop but it seems the div id is a fixed reference and as such I cannot use this within a loop as the div id can only be referenced one time.
I am looking for a solution to somehow allow the jquery popup script to support dynamic div id's but not sure how to do that.
Here is my html/php code where i can assign a dynamic div id:
$counter is a number, the number increases on every loop i.e. inline-popups1, inline-popups2 etc..
$content = "<!-- Jquery reference -->
<div id='inline-popups".$counter."'>
<!-- Popup link -->
<a href='#popup".$counter."'>Popup Link</a>
</div>
<!-- Popup itself -->
<div id='popup".$counter."' class='white-popup mfp-with-anim mfp-hide'>
<p>content goes here</p>
</div>";
Here is the jquery - as you can see $('#inline-popups') is a fixed referenced. I need it to support the dynamic references as shown above.
// Inline popups
$(document).ready(function() {
$('#inline-popups').magnificPopup({
delegate: 'a',
removalDelay: 500, //delay removal by X to allow out-animation
callbacks: {
beforeOpen: function() {
this.st.mainClass = this.st.el.attr('data-effect');
}
},
midClick: true // allow opening popup on middle mouse click. Always set it to true if you don't provide alternative source.
});
});
<div id='inline-popups".$counter."'>as thats what is referencing the jquery script.. but how to make the jquery accept that call ?