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?
@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
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(); }); }); }
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?