jquery - Click on dynamically added element in Magnific Popup not detected. Trying to navigate to next item on click of current item in ajax gallery -


I am creating an image gallery where full-size images are presented in a lightbox. The content of the lightbox is AJAX loaded html from the external file. I am using this script for this behavior. I am trying to do this so that you can navigate to the next gallery image directly by clicking anywhere on the current image displayed in the lightbox Are there. The problem is that I am unable to locate the click event, although it has been explicitly inserted into the dom.

Main view: main.html

  & lt; Div class = "gallery" & gt; & Lt; A href = "gallery.php? Photo = image-1.jpg" & gt; Thumbs-1.jpg & lt; / A & gt; & Lt; A href = "gallery.php? Photo = image-2.jpg" & gt; Thumbs-2.jpg & lt; / A & gt; & Lt; A href = "gallery.php? Photo = image-3.jpg" & gt; Thumbs-3.jpg & lt; / A & gt; & Lt; / Div & gt;   

Lightbox content: gallery.php

  & lt ;? Php echo '& lt; Img class = "item" src = "img / '. $ _GET [' photo ']." "& Gt; ';? & Gt;   

jQuery:

  $ (' gallery '). MagnificPopup ({Representative: 'A', Type: 'Ajax', Gallery: {Enabled: True, Navigating BIMGClique: True}})}}   

I have not shown any navigateByIggClick option, it seems that this is done to set things that clicking the current gallery item will take you to the next gallery item, however, At least in my trial, it's ajax c The slider does not work for (when type is set to ajax .) So what I did is add a snippet to see if The click event is being found:

  $ ('. Item'). ('Click', function () {warning (click 'found');}); < However, click is never found (warning has not been clicked on).  

Most First, why not click Being not?

Second, how to set up the next gallery item when using an AJAX gallery?

Understand this. Need to assign the image to .mfp-img Now it is working. This gorgeous popup can be searched by this part of the source:

  if (gSt.navigateByImgClick) {mfp.wrap.on ('click' + ns, '.mfp-img', function () {If (mfp.items.length & gt; 1) {mfp.next (); Return false;}}); }    

Comments

Popular posts from this blog

python - how we can use ajax() in views.py in django? -

matlab - Using loops to get multiple values into a cell -

python - Sequence Pattern recognition with Pybrain -