Image gallery script lightbox problems

Hello so iam kinda new to scripts and ect and i need some help
So iam using this script

Every thing works if i use one div gallery but when i close it and open again script does not work anymore. So i was thinking no problem i will just open div gallery somewhere on top and wont close it but… if there is option like “read more” or link it will track it as a image and will stuck.
Like this it works

<div id="gallery"> 
<!-- Regular images --> 
<a href="images/1 . jpg"><img src="images/1_thumb . jpg"  alt="" title="Išorė (#1)" /></a> 
<a href="images/1 . jpg"><img src="images/1_thumb . jpg"  alt="" title="Išorė (#1)" /></a> 
</div>

but if i try open another div with same name it will stop working…
Image what i have in my mind http://image.prntscr.com/image/cd21d10a400b4cd9b0face04228e8012.png
what i wanna do is,

<p> some random text about something </p>
<div id="gallery"> 
<!-- Regular images --> 
<a href="images/1 . jpg"><img src="images/1_thumb . jpg"  alt="" title="Išorė (#1)" /></a> 
</div>

NEW POST

<p> some random text about something </p>
<div id="gallery"> 
<!-- Regular images --> 
<a href="images/1 . jpg"><img src="images/1_thumb . jpg"  alt="" title="Išorė (#1)" /></a> 
</div>

for now with that script i cant do that becouse second post will not work it will open full size image in new tab

<hr>
<div align="justify">
	<form>
<fieldset>
<br>

<small><strong> 2017-02-28 │ TITLE NAME </strong> </small>
<br>

<p> some text about what  happened</p>
<p>MORE details text about what happened</p>
<p>what will happen next text

<br>
</p><center>
<div id="gallery"> 
<!-- Regular images --> 
<a href="images/1 . jpg"><img src="images/1_thumb . jpg"  alt="" title="Išorė (#1)" /></a> 
</div>
</center>
<br>	

	</fieldset></form>
</div>
<hr>

is there is anyway i can do it like that? open again <div id="gallery"> in new post and some image close it and repeat

Do you have two or more wrappers with the same ID?If yes I think that is the cause of the problem

All post are in <form> not in wrappers

The document of the script said that _“2. Wrap the html content in a wrapper and add a link to the thumbnail image that you want to open its large version in the popup window…”

In that case i think div gallery goes for wrapper. or maybe i dont get it, can you give me example of what you mean

Ok as i see your code you don’t have this case.Because your image (as I undersatnd) load via php variable so the script maybe don’ t find the src value.Try this code:

($(document).ready(function(){
$('#gallery').poptrox({
usePopupCaption: true
});
}));

Also check your console for possible errors and if you have show us them.

it find first time but not second short video of my problem

(this is not actual light box so i think that why it wont work)

Just tried with normal lightbox works nice also with fancybox3

This is happen because you use the function with the element id selector, so the function takes the first element that find.
The suggest solution is to add class attr and work like this:

<div class="gallery"> 
.
.
.
.
</div>


($(document).ready(function(){
 
  $('.gallery')[0].poptrox({
usePopupCaption: true
});
  
   $('.gallery')[1].poptrox({
usePopupCaption: true
}); 
  
  
}));



Thank you works with class now

<div class="gallery"> 
.
.
.
.
</div>

now i can add as many same class i want

<div class="gallery"> 
.
.
.
.
</div>

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.