Turns out there was an unclosed <script>
tag, due to which close button went right inside it and this wasn't shown in inspect element option of browsers...
jQuery Click Event firing on right click only ~ Magnific Popup ~ Magento
Question
Situation: I have a Magnific Popup on a magento site & it is using ajax but for some reason the close button isn't working!
Demo: Well i cant show you the site as it's under-development and it will take too much time to replicate the issue on fiddle.
What i have tried: Since the default functionality isn't working and after wasting a lot of time, i tried to find my work around by applying a click event on close button to force close the popup:
jQuery(document).bind('click', function(e) {
jQuery("mfp-close").unbind(); //incase any other event is conflicting.
var lookForCloseBtn = jQuery(e.target);
if (jQuery(lookForCloseBtn).hasClass("mfp-close")){
var magnificPopup = jQuery.magnificPopup.instance;
magnificPopup.close();
}
});
This dosent do the trick but if i right click the close button, the code works!! i have no clue what is going on..... how can i make it respond to left click?
Any suggestions are welcome!
Edit: I tried binding a random "alert" msg on document click using console while the popu was open ~ click event only triggered when i right clicked any part of popup but the same code will be triggered on left click without the popup!!
Solution