# Dynamic Page Lightboxes

**URL:** <https://forum.wixstudio.com/t/dynamic-page-lightboxes/20002>\
**Category:** Ask the community\
**Tags:** wix-bookings, question, code\
**Created:** [January 22, 2018, 1:47am UTC](https://forum.wixstudio.com/t/dynamic-page-lightboxes/20002 "2018-01-22T01:47:10Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_mnl](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/_mnl/32/1667_2.png) [@\_mnl](https://forum.wixstudio.com/u/_mnl)\
**Post date:** [January 22, 2018, 1:47am UTC](https://forum.wixstudio.com/t/dynamic-page-lightboxes/20002/1 "2018-01-22T01:47:10Z")

</div>

Hi guys. How to create a dynamic lightbox with contact and detail info from the database?  
My site is a “room booking” kind. So when I click “book it now” a lightbox with info from the room should open.  
Any idea? Thanks.

ps: my site already has databases, dynamic map and dynamic image gallery.

---

<div class="post-metadata">

**Author:** ![roi-bendet](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/roi-bendet/32/1283_2.png) [@roi-bendet](https://forum.wixstudio.com/u/roi-bendet)\
**Post date:** [January 22, 2018, 11:16am UTC](https://forum.wixstudio.com/t/dynamic-page-lightboxes/20002/2 "2018-01-22T11:16:46Z")

</div>

Hi,  
It is possible to communicate between the page and the light box.  
For example:

```javascript
wixWindow.openLightbox("Your lightbox",{data:'the information you want to pass'});// from the page that opens the lightbox

```

And the code in the lightbox:

```javascript
let receivedData = wixWindow.lightbox.getContext(); // to receive the information

```

When closing the lightbox:

```javascript
wixWindow.lightbox.close({wantsToBookTheRoom:true}); 

```

For more information read this:

> **[Lightbox - Velo API Reference - Wix.com](https://www.wix.com/velo/reference/wix-window-frontend/lightbox)**
>
> A lightbox pops up on your site to grab your visitor's attention.

Good luck!  
Roi

---

<div class="post-metadata">

**Author:** ![\_mnl](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/_mnl/32/1667_2.png) [@\_mnl](https://forum.wixstudio.com/u/_mnl)\
**Post date:** [January 22, 2018, 2:51pm UTC](https://forum.wixstudio.com/t/dynamic-page-lightboxes/20002/3 "2018-01-22T14:51:13Z")

</div>

Thanks Roi.  
But I have some difficult writing codes…I’m not a developer.  
How do I set the button “book now” to open that specific lightbox?  
Where do I find the name of the lightbox?  
Don’t I need to write import wixWindow from ‘wix-window’; before these codes?

---

<div class="post-metadata">

**Author:** ![roi-bendet](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/roi-bendet/32/1283_2.png) [@roi-bendet](https://forum.wixstudio.com/u/roi-bendet)\
**Post date:** [January 24, 2018, 9:12am UTC](https://forum.wixstudio.com/t/dynamic-page-lightboxes/20002/4 "2018-01-24T09:12:27Z")

</div>

Hi,  
Some coding skills are required in order to code in Wix Code.  
You can hire an expert in [Wix Arena](https://www.wix.com/arena/info/how-it-works) .  
Or, you can try coding!  
In order to set the button you need to create onClick event and use openLightbox() method like i wrote in the example above.  
This [article](https://support.wix.com/en/article/working-with-events-in-wix-code) will help to create events to elements.  
Roi

---

<div class="post-metadata">

**Author:** ![linaabadir](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/linaabadir/32/12514_2.png) [@linaabadir](https://forum.wixstudio.com/u/linaabadir)\
**Post date:** [September 27, 2019, 11:45am UTC](https://forum.wixstudio.com/t/dynamic-page-lightboxes/20002/5 "2019-09-27T11:45:48Z")

</div>

Hi Roi  
I was wondering if this is do able from a Dynamic Page to LightBox ?as i want to pass a variable from a dataset to the lightbox ?  
thanks  
Lina

---

<div class="post-metadata">

**Author:** ![code-queen](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-queen/32/696_2.png) [@code-queen](https://forum.wixstudio.com/u/code-queen)\
**Post date:** [September 27, 2019, 12:11pm UTC](https://forum.wixstudio.com/t/dynamic-page-lightboxes/20002/6 "2019-09-27T12:11:36Z")

</div>

Hello Lina…

I have a tutorial that can show you how to grab information then display it in a lightbox.

This specific tutorial gets information from a repeater, but you can basically modify your code to get current item from dynamic dataset instead.

Here is a link to the tutorial:  
[https://support.totallycodable.com/en/article/open-a-lightbox-when-clicking-an-item-in-a-repeater-using-a-button](https://support.totallycodable.com/en/article/open-a-lightbox-when-clicking-an-item-in-a-repeater-using-a-button)

---

<div class="post-metadata">

**Author:** ![linaabadir](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/linaabadir/32/12514_2.png) [@linaabadir](https://forum.wixstudio.com/u/linaabadir)\
**Post date:** [September 30, 2019, 11:03am UTC](https://forum.wixstudio.com/t/dynamic-page-lightboxes/20002/7 "2019-09-30T11:03:43Z")

</div>

Thank you Queen , So in my case i have a dynamic data set (Item) , so my code will be as below bit confused how to edit the repeater part cause the item is already ready right ? :

$w.onReady( **function** () {

$w(“#dynamicDataset”).onReady(() =\> {

$w(“#repeater”).ItemReady(($item, itemData, index) =\> {  
$item(‘#Button’).onClick(() =\> {  
**let** item = $item(‘#dynamicDataset’).getCurrentItem();  
wixWindow.openLightbox(‘Lightbox’, item)  
});  
});

});

---

<div class="post-metadata">

**Author:** ![code-queen](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-queen/32/696_2.png) [@code-queen](https://forum.wixstudio.com/u/code-queen)\
**Post date:** [September 30, 2019, 1:40pm UTC](https://forum.wixstudio.com/t/dynamic-page-lightboxes/20002/8 "2019-09-30T13:40:17Z")

</div>

You would remove the ‘repeater’ line altogether and keep everything in between. Since your button is not in a repeater the onClick line would look like this instead: [https://www.wix.com/corvid/reference/$w.Button.html#onClick](https://www.wix.com/corvid/reference/$w.Button.html#onClick)

---

<div class="post-metadata">

**Author:** ![linaabadir](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/linaabadir/32/12514_2.png) [@linaabadir](https://forum.wixstudio.com/u/linaabadir)\
**Post date:** [October 2, 2019, 7:38am UTC](https://forum.wixstudio.com/t/dynamic-page-lightboxes/20002/9 "2019-10-02T07:38:19Z")

</div>

Dear Code Queen  
I tried alot to remove the repeater but now i guess i am loosing the line that prepares the item value ( if i am understanding the code right logic) so when i placed the on click line the TargetId is not readable

$w.onReady( **function** () {

$w(“#dynamicDataset”).onReady(() =\> {  
$w(“#text54”).onClick( (event) =\> {  
**let** targetId = event.target.id; // “myElement”  
} );

```
wixWindow.openLightbox('lightbox',targetId) 

```

});  
});

thanks  
Lina

---

<div class="post-metadata">

**Author:** ![tfigueiracosta](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/tfigueiracosta/32/15047_2.png) [@tfigueiracosta](https://forum.wixstudio.com/u/tfigueiracosta)\
**Post date:** [May 21, 2020, 1:40am UTC](https://forum.wixstudio.com/t/dynamic-page-lightboxes/20002/10 "2020-05-21T01:40:19Z")

</div>

hello Lina, have you made yet?

---

<div class="post-metadata">

**Author:** ![tfigueiracosta](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/tfigueiracosta/32/15047_2.png) [@tfigueiracosta](https://forum.wixstudio.com/u/tfigueiracosta)\
**Post date:** [May 21, 2020, 1:49am UTC](https://forum.wixstudio.com/t/dynamic-page-lightboxes/20002/11 "2020-05-21T01:49:39Z")

</div>

Hello, i have the same problen, can someone help

---

<div class="post-metadata">

**Author:** ![tfigueiracosta](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/tfigueiracosta/32/15047_2.png) [@tfigueiracosta](https://forum.wixstudio.com/u/tfigueiracosta)\
**Post date:** [May 21, 2020, 2:05am UTC](https://forum.wixstudio.com/t/dynamic-page-lightboxes/20002/12 "2020-05-21T02:05:29Z")

</div>

@code-queen can u explain this … I also removed the repeater line and change as show on LINK u sent, but then then i got error on lasT line

### 

import wixWindow from ‘wix-window’ ;  
import wixData from ‘wix-data’ ;

$w.onReady(() =\> {

$w( “#dynamicDatasetAngra” ).onReady(() =\> {

$w( “#button3” ).onClick( (event) =\> {  
let targetId = event.target.id;

=======IT SAYS " $ **item**" IS NOT DEFINED =========

let item = $item( ‘#dynamicDatasetAngra’ ).getCurrentItem();  
wixWindow.openLightbox( ‘Cheese’ , item)

});

});

});
