BUG? issue with repeaters on LightBox

Hi,
I’m using code the following code and i have error that i not have on regular page - only on Light Box page:
export function repeater1_itemReady($item, itemData, index) {
$item(" #name ").text = itemData.cityName;
$item(’ #container1 ').onClick(() => {
});
}

add “repeater1_itemReady” on the properties panel

i’m using repeater with text element inside the container
when i’m configure itemReady i get on my element inside the repeater the following error:
‘text’ dos not exist on ’ #name

anyone know how to resolve this?

Are you saying that the repeater you used on your page, you also have a copy of the repeater in your lightbox?

What is it that you are trying to accomplish in your lightbox? Are you following a specific tutorial?

Hi @code-queen ,
i’m trying to use search with dropdown
got it from here:
https://www.wix.com/corvid/forum/corvid-tips-and-updates/example-repeater-dropdown-with-keyboard-navigation

its something like the new address_input but in Hebrew

and i want it on light box
on regular page its working fine
so i think is a bug on light box

Thank you

So you are using Yisrael’s Gramps example.
https://www.grampsworkbench.com/Examples/Repeater-Dropdown

For starters Yisrael has the repeater set as collapsed on load and not hidden on load.


Plus, make sure that your onItemReady does not have the _1 added to the end of it when you add it through the properties panel for the repeater.

His code from the tutorial is…

import wixData from 'wix-data';

const HL_COLOR = "rgba(190,190,250)";
const REG_COLOR = "rgba(222,222,222)";

let listSize;
let currIndex = -1;

$w.onReady(function () {

$w('#input').onKeyPress((event) => {
setTimeout(() => {
if ($w('#input').value.length === 0) {
currIndex = -1;
$w("#rptDropdown").collapse()
.then(() => {
console.log("Done with collapse");
});
} else {
switch (event.key) {
case "Enter":
$w('#input').value = $w('#rptDropdown').data[currIndex].title;
$w("#rptDropdown").collapse()
.then(() => {
console.log("Done with collapse");
});
break;
case "ArrowLeft":
case "ArrowRight":
break;
case "ArrowUp":
if (currIndex > 0) {
currIndex -= 1;
refresh_repeater();
}
break;
case "ArrowDown":
if (currIndex < listSize - 1) {
currIndex += 1;
refresh_repeater();
}
break;
case "Escape":
$w('#input').value = '';
currIndex = -1;
$w("#rptDropdown").collapse()
.then(() => {
console.log("Done with collapse");
});
break;
default:
currIndex = -1;
wixData.query("Countries")
.startsWith("title", $w('#input').value)
.ascending("title")
.limit(5)
.find()
.then((res) => {
$w('#rptDropdown').data = [];
$w('#rptDropdown').data = res.items;
listSize = res.items.length;
$w('#rptDropdown').expand();
});
break;
}
}
}, 50)
});
});

export function rptDropdown_itemReady($item, itemData, index) {
$item('#name').text = itemData.title;
if (index === currIndex) {
$item("#rptBox").style.backgroundColor = HL_COLOR;
} else {
$item("#rptBox").style.backgroundColor = REG_COLOR;
}

$item('#container1').onClick(() => {
$w('#input').value = itemData.title;
$w('#rptDropdown').collapse();
});
}

function refresh_repeater() {
$w("#rptDropdown").forEachItem(($item, itemData, index) => {
$item('#name').text = itemData.title;

if (index === currIndex) {
$item("#rptBox").style.backgroundColor = HL_COLOR;
} else {
$item("#rptBox").style.backgroundColor = REG_COLOR;
}

$item('#container1').onClick(() => {
$w('#input').value = itemData.title;
$w('#rptDropdown').collapse();
});
});
}

I have just tried exactly the same thing on a new website on a page and in a lightbox, which you can view and it all works fine on both the page and the lightbox using the code from Yisrael.

i have not altered anything from the example itself and have kept all id names the same so that the code could just be copied into the page and lightbox page to work straight away.

https://givemeawhisky.wixsite.com/mysite-1

@givemeawhisky
Hi,
thanks for your answer
now, without changing anything its working with the same code that did not work before
with the hide and everything
i think they fix it.

Thanks

@naimibaby

Okay firstly I doubt that anything was fixed due to a bug, otherwise Yisrael or somebody else would have mentioned it on here if they read your post about it.

Plus, if I went by your logic then it should not have been working for me either when I did that test site with it on a page and on a lightbox.

The only difference being that you had cropped out the code for the highlighted repeater box so you just get a plain white background.

export function rptDropdown_itemReady($item, itemData, index) {
$item('#name').text = itemData.title;
$item('#container1').onClick(() => {
});
}

Which in all fairness is not brilliant as it be better to have a background still on the repeater list so that it is not overlapping anything else on the page or lightbox and is clear and easily viewable and readable for your user.

export function rptDropdown_itemReady($item, itemData, index) {
$item('#name').text = itemData.title;
if (index === currIndex) {
$item("#rptBox").style.backgroundColor = HL_COLOR;
} else {
$item("#rptBox").style.backgroundColor = REG_COLOR;
}

Plus, for some strange reason you took out the code below the onClick function for the container which when clicked on, it would make the

$item('#container1').onClick(() => {
$w('#input').value = itemData.title;
$w('#rptDropdown').collapse();
});
}

Now that you have done that, when you click on container within the repeater, then the list of countries that it is displaying will not collapse and they will still appear on the page itself.

I have just tested your code crops on Yisrael’s test site and I am correct, there is no background to the country list and it now does not collapse when the container inside the repeater is clicked on.

As I have already stated above, you really needed a background to that list and especially so it is distinguishable from the page or lightbox itself and makes it connected to the search input itself.

So note that with this line here - $item(‘#container1’).onClick(() => {

It is an onclick event handler function which has the event handler already written into the code so that you don’t have to use the properties panel of that element to add it yourself.

The only difference with it from normal, like the earlier one in the code for the onKeyPress event handler - $w(‘#input’).onKeyPress((event) => { - is that this container is inside a repeater and so must be done by $item and not simply by $w.

You can see more about this in the Repeater section in the Wix API Reference here, which I would suggest that you read if you are using repeaters.

Therefore, that onClick event handler function on the container is looking for something to do after the container inside the repeater is clicked, which in this case is to tell the list of countries to be collapsed and not shown anymore.

Without those other two lines of code underneath the container onClick event handler, then you don’t get the country list being collapsed and you end up with a list that appears on your screen all the time, as shown in the previous pic above.

As for your original question in your post about it saying an error with text on the element called #name.

This would be a prime example of using the ‘Layers’ button on the bottom of the toolbar, so that you can get a list of all the elements on that page and just double check that you haven’t missed anything out, or done something like put it as a user input and not a text box element.

See here about using the Layers option from within Wix Editor and you would get this on your page. Wix Editor: Using the Layers Panel | Help Center | Wix.com

Finally, with you saying that you used hidden on load instead of collapsed on load in your page, as shown in the pic back up this post and on your original post.

Then with it hidden on load, then the repeater would never appear when you type anything into the search box as there is nothing in the code telling the repeater which is hidden to be shown.

You can see it here in this pic that the repeater does expand and move everything down on the page itself, however as you have not told the repeater to be shown in your code with the .show() function, then it will still be hidden even though the repeater itself is expanding and collapsing.

Please note also, that there is a difference with the functions of show and hide compared to the functions of expand and collapse.

When you hide something on your page, you are simply hiding it from view and it is still on your page and taking up that same space on your page, so when you use show to show it again then it will just appear exactly where it is on your page regardless of if you have anything else behind it or in front of it.

When you collapse something on your page, you are collapsing it which means that it does not take up any room on your page and hence why everything moves to make room for it when you expand it again.

You can again read move about this in the Wix API Reference.

Show/Hide - HiddenMixin - Velo API Reference - Wix.com
Expand/Collapse - CollapsedMixin - Velo API Reference - Wix.com

Also, as you say it is now working for you without changing any of your code etc, then please paste up here your code that you have used on your page so that I can have a look at it as I am curious now as to what you have used on your page.

Especially, if you say that you haven’t changed anything and that the repeater which should be set to be collapsed on load, is still set to be hidden on load instead.

Plus, add a screenshot of the repeater properties so that I can see that you still have it on hidden on load.

Nobody is aware of any bug or any fix that has been made and like I said, I’ve got it working on both page and lightbox using the original code, so it will be interesting to see what you have it setup as so that I can see if I can copy your setup to see if I get a repeat of any bug that you think is happening here.

@givemeawhisky
WoW!
thank you for the long explanations
my code above is just an example of code that not working for me

my fully code is:

import wixData from 'wix-data';
import {fetch} from 'wix-fetch';
let listSize;
let currIndex = -1;
import wixWindow from 'wix-window';
var CityNameFromLightBox
var AddressNameFromLightBox
var HouseNumberFromLightBox
$w.onReady( function () {

$w('#input11').onKeyPress((event) => {
setTimeout(() => {
if ($w('#input11').value.length === 0) {
currIndex = -1;
//$w('#input6').disable();
$w("#rptDropdown").hide()
.then(() => {
console.log("Done with collapse");
});
} else {
switch (event.key) {
case "Enter":
$w('#input11').value = $w('#rptDropdown').data[currIndex].title;
$w("#rptDropdown").hide()
.then(() => {
console.log("Done with collapse");
});
break;
case "ArrowLeft":
case "ArrowRight":
break;
case "ArrowUp":
if (currIndex > 0) {
currIndex -= 1;
refresh_repeater();
}
break;
case "ArrowDown":
if (currIndex < listSize - 1) {
currIndex += 1;
refresh_repeater();
}
break;
case "Escape":
$w('#input11').value = '';
currIndex = -1;
//$w('#input6').disable();
$w("#rptDropdown").hide()
.then(() => {
console.log("Done with collapse");
});
break;
default:
currIndex = -1;
wixData.query("israelCitys2019")
.startsWith("cityName", $w('#input11').value)
.ascending("cityName")
.limit(3)
.find()
.then((res) => {
$w('#rptDropdown').data = [];
$w('#rptDropdown').data = res.items;
listSize = res.items.length;
$w('#rptDropdown').show();
});
break;
}
}
}, 50)
});
});

export function rptDropdown_itemReady($item, itemData, index) {
$item("#name").text = itemData.cityName;
if (index === currIndex) {

$item('#container1').onClick(() => {
$w('#input11').value = itemData.cityName;
$w('#rptDropdown').hide();
//$w('#input6').enable();
});
}

function refresh_repeater() {
$w("#rptDropdown").forEachItem(($item, itemData, index) => {
$item('#name').text = itemData.cityName;
$item('#container1').onClick(() => {
$w('#input11').value = itemData.cityName;
$w('#rptDropdown').hide();
});
});
}

//----------------------------------------------------------------------
import {getChitaShops} from 'backend/serviceModule';
import {getChitaStors} from 'backend/serviceModule';
var cityName
var cityCode
export function findChitaStors(event) {
cityName = $w('#input11').value
wixData.query("israelCitys2019")
.eq("cityName", cityName)
.limit(1)
.find()
.then((res) => {
cityCode=res.items[0].citySymbol;
console.log("cityCode: ", cityCode)
getChitaShops(cityName, cityCode)
.then( (xml) =>{
console.log("xml response: ", xml)
return true
});
});
}

function searchAddress () {
var storeRows = []
getChitaStors()
.then((xml2) => {
console.log("xml2 response: ", xml2)
let spots = xml2.root.spots.spot_detail
console.log("spots: ", spots)
spots.forEach((item) => {
storeRows.push({
store_name: item.name,
store_address: item.street + " " + item.house + " " + item.city,
store_hours: item.remarks
});
$w("#storesTable").rows = storeRows;
});
});
}

export function searchAddress_click () {
findChitaStors()
setTimeout(() => {
searchAddress()
},3000);
}

export function button58_click(event) {
wixWindow.lightbox.close()
}

in the backend i’m pointing to external API with fetch

finally after long time i can use it on light box (with just copy it to the lightbox)
and its working great
thank you for your help @givemeawhisky