Dynamic Lightboxes for Videos using a Dataset URL?

I have a dataset with text fields and a URL field
I have created a table, and want do display the video that relates to the row that is selected in a lightbox.
How do you do that?

The Table has fields as follows:
“Title”
“Description”
“Author”

The dataset it is linked to also has a field called
“Link” (which is a URL type field)

I’ve not though shown this field in the Table displayed on the page (the URLs are too long).

I’ve looked at the onrowselect, and row commands, and oncurrentindexchange and get selected item commands, but cannot get the wix window open lightbox functions to work properly.

The Tabel ID is “Video Tutorials”
The Lightbox page and Lightbox ID are called “Video Lightbox”

Any help would be greatly appreciated!

WixTeam and Forum Members,

Any luck with solving this?

Problem is similiar to another post using Table Cell Select to open that image in a Lightbox.

My problem is slightly different. I want to load the video into a lightbox.

Dataset:
The videos are on youtube, and their URLs are referenced in a dataset called “Video Tutorials”, in a field called “Link” , with field type “URL”

On the page I’ve created: The Table has fields as follows:

“Title”
“Description”
plus a few more purely decriptive text fields

The Table is linked to a dataset called “Video Tutorials”, which has a field called
“Link” (which is a URL type field) - where the Video URLs are stored

Right now, I’ve just included the Video URLs as a linkpath to the first column (Called “Title” of the Table)

See here >> (bottom half of page)

https://sachin1882.wixsite.com/startechcapital/guides

I’d like it so that when a particular row is selected, it opens the video (related to that row) in a lightbox
OR, that
when the linkpath of the first column is clicked, that it doesn’t open the link in a new window - as it currently does -, but opens it in a lightbox

I don’t think the second option is possible, and I’m failing at the first. : - (

  • Sachin

Hi,
Here are some references for your issues:

Please update with your progress
Roi

I’ve now created the lightbox, and connected it to my video tutorial dataset, connecting its source to the Video URL in that Dataset.

I’ve used the onclick event to call the onrowselect function for the Table object (which is located on another page), and called the open lightbox function.

The ligthbox does open, with the video that plays. The only problem is that, regardless of which row in the table I click on, the “same” video loads into the lightbox.

See here>> https://sachin1882.wixsite.com/startechcapital/guides
Table is at the bottom of the page. Try clicking on any row (but don’t click on the first column’s linkpath).
The same video opens no matter what?

  • Sachin

Guys,

I made some progress, but, the same video keeps loading, regardless of which row I select…

Any thoughts on a solution?

Sachin

Hi Sachin,
Yes, it is possible to add props when opening a lightbox.
My suggestion is to add the source url and to use getContext method when is opens.
Please update in your progress.
Roi

Hi Roi,

How would I do this?

Currently, the code in this page (https://sachin1882.wixsite.com/startechcapital/guides) for the Table at the bottom is:

import wixWindow from ‘wix-window’;

export function table1_rowSelect(event, $w) {
//Add your code for this event here:

//$w("#VideoTutorialsDataset").onCurrentIndexChanged((event, $w) { 
	//let itemData = $w("#VideoTutorialsDataset").getCurrentItem(); 
//}); 
//let cellData = itemData["Link"]; 

wixWindow.openLightbox("Video Tutorial"); 

}

The lightbox (which is it’s own page) has no code, but is linked to the Video Tutorials Dataset which itself has the URLs (youtube links) for each video.

The GetContext( ) guides and instructions aren’t very clear (at least to a novice like me)

Thanks in advance,

Sachin

Hi again,
On rowSelect function open the lightbox with props.
Like this:

wixWindow.openLightbox("Video Tutorial",event.rowIndex);

In the lightbox page you need to disconnect the video element from the dataset and add some code.
The code should look like this:

import wixWindow from 'wix-window';
$w.onReady(function () {
	const dataFromTableRow = wixWindow.lightbox.getContext(); // equals to the index number of the item in the dataset
	$w('#yourDataset').setCurrentItemIndex(dataFromTableRow)
		.then(() => {
			const currentItem = $w('#yourDataset').getCurrentItem();
			$w('#yourVideo').videoUrl = currentItem.link;
		});
});

Please update in your progress.
Good luck!
Roi

Hi i tried this

Tutorial Code:

$w.onReady(function () {
//TODO: write your page related code here…

});

import wixWindow from 'wix-window'; 

export function table1_rowSelect(event, $w) { 
wixWindow.openLightbox("Video Tutorial"); 

}

Lightbox Code:

import wixWindow from ‘wix-window’;

$w.onReady(function () {
const dataFromTableRow = wixWindow.lightbox.getContext(); // equals to the index number of the item in the dataset
$w(‘Video Tutorials’).setCurrentItemIndex(dataFromTableRow)
.then(() => {
const currentItem = $w(‘VideoTutorials’).getCurrentItem();
$w(‘Link’).videoUrl = currentItem.link;
});
});

The name of the lightbox is: ‘Video Tutorials’
The name of the dataset is: ‘VideoTutorials’
The name of the field in the dataset with the link is: ‘Link’

I now get an error in the Preview editor that says:

TypeError: $w(…).setCurrentItemIndex is not a function

And the lightbox just loads the default Wix Basketball Video, regardless of which row of the table you select?

  • Sachin

Any thoughts?

Hi again,
If this is your error :TypeError: $w(…).setCurrentItemIndex is not a function so you got the wrong name of the dataset element.
“Video Tutorials” is the name of the database collection and not the dataset element’s name.
Go to “view properties” on the menu’s element and you will see the id of the element.
Roi

Hi,

I think I’m very very close, though didn’t quite get your description. I didn’t quite get what you meant by “view properties” on the menu’s element. What is the menu element?

Is the dataset the ID of the Table element, or ID of the LightBox?

I tried both this:

$w.onReady(function () {
const dataFromTableRow = wixWindow.lightbox.getContext(); // equals to the index number of the item in the dataset
$w(‘LightBoxVideo’).setCurrentItemIndex(dataFromTableRow)
.then(() => {
const currentItem = $w(‘LightBoxVideo’).getCurrentItem();
$w(‘Link’).videoUrl = currentItem.link;
});
});

and this:

$w.onReady(function () {
const dataFromTableRow = wixWindow.lightbox.getContext(); // equals to the index number of the item in the dataset
$w(‘VideoTutorials’).setCurrentItemIndex(dataFromTableRow)
.then(() => {
const currentItem = $w(‘VideoTutorials’).getCurrentItem();
$w(‘Link’).videoUrl = currentItem.link;
});
});

In summary:

The name of the lightbox is: ‘Video Tutorial’
The name of the datacollection is: ‘VideoTutorials’
The name of the field in the datacollection with the link is: ‘Link’
The ID of the Table is: ‘VideoTutorials’
The ID of the Lightbox is ‘LightBoxVideo’

The same error still appears in the developer:

TypeError: $w(…).setCurrentItemIndex is not a function

You need to set the correct name of the dataset.
Here is example:


The name of the database collection is Members but the name of the dataset is ‘dataset1’.
So, if I want to reach it in code I should write:

$w('#dataset1')

Did as you said, but it Still doesn’t work:

Guide Page Code:
$w.onReady(function () {
//TODO: write your page related code here…

});

import wixWindow from 'wix-window'; 

export function table1_rowSelect(event, $w) { 
wixWindow.openLightbox("Video Tutorial"); 

}

Lightbox Code:

// For full API documentation, including code examples, visit Velo API Reference - Wix.com

import wixWindow from ‘wix-window’;

$w.onReady(function () {
const dataFromTableRow = wixWindow.lightbox.getContext(); // equals to the index number of the item in the dataset
$w(‘VideoDataset’).setCurrentItemIndex(dataFromTableRow)
.then(() => {
const currentItem = $w(‘VideoDataset’).getCurrentItem();
$w(‘Link’).videoUrl = currentItem.link;
});
});

Name of Dataset

Name of Lightbox


Erro when I click on any row in the Table

Any ideas?

https://sachin1882.wixsite.com/startechcapital/guides

You missed # sign
$w(’ # VideoDataset’).setCurrentItemIndex(dataFromTableRow).
Roi

Thanks.

But that doesn’t appear to be it:

Lightbox Code:

// For full API documentation, including code examples, visit Velo API Reference - Wix.com

import wixWindow from ‘wix-window’;

$w.onReady(function () {
const dataFromTableRow = wixWindow.lightbox.getContext(); // equals to the index number of the item in the dataset
$w(‘#VideoDataset’).setCurrentItemIndex(dataFromTableRow)
.then(() => {
const currentItem = $w(‘#VideoDataset’).getCurrentItem();
$w(‘#Link’).videoUrl = currentItem.link;
});
});

Guides Page Code:

// For full API documentation, including code examples, visit Velo API Reference - Wix.com

$w.onReady(function () {
//TODO: write your page related code here…

});

import wixWindow from 'wix-window'; 

export function table1_rowSelect(event, $w) { 
wixWindow.openLightbox("Video Tutorial"); 

}

Dataset Name

Error when I click on any row in the table:
Video pops up (the default WIX basketball one), and this shows in the developer console


I’m starting to think, this won’t actually work : (

Hi,
I checked your site.
You need to add props when you open the lightbox

wixWindow.openLightbox("Video Tutorial",event.rowIndex);

And you need to add dataset element to the lightbox
Roi

Ok,

I think I’ve done the first bit:

  1. I changed the Guides page code to:

$w.onReady(function () {
//TODO: write your page related code here…

});

import wixWindow from 'wix-window'; 

export function table1_rowSelect(event, $w) { 
wixWindow.openLightbox("Video Tutorial", **event.rowIndex** ); 

}

(I’ve included the event.rowIndex in the OpenLightBox function

What did you mean by this - “And you need to add dataset element to the lightbox”

I linked the VideoDataset to the Lightbox Again… but left Video URL connects to, to Not Connected (see below)

I’m also pretty sure the names of the dataset on the lightbox page are all correct

There is now no error, but it loads only the default WIX video, regardless of which row in the table I select

What is #Link element ?

The name of the field in the dataset which has the video urls