Two clicks needed to fire modal

Thanks @m_hutley, @Paul_Wilkins

I understand the document ready regarding the short hand with jquery. The problem is trying to use this plugin and fire it on single click within the Mustache template engine.

As outlined in an older thread using a diffrent plugin, I had the same issue which @m3g4p0p described as event delegation.

Example

This works when not using MustacheJS
$('.popup').magnificPopup({});

But when using MustacheJS - I need to add $(document)
$(document).on('click', '.popup', function(e){}

I’ve updated/created a new jsfiddle so you can see the Mustache template working with the popup needing 2 clicks.

Hope this makes sense.

Thanks,
Barry