My client needs this update tomorrow.
This code worked on my dynamic pages before, but now that I have adjusted it for a repeater and forEachItem,
I keep getting this error when I can get the preview to work.
TypeError: Cannot read property ‘compId’ of undefined
Everything is so slow to load and my preview is not working when I click on it.
Here is my code:
$w.onReady(function ( ) {
$w('#dataset1').onReady ( ( ) => {
$w("#repeater1").forEachItem( ($item, itemData, index) => {
$item("#email").link = 'mailto:' + itemData.email;
$item("#phone").link = 'tel:' + itemData.phone;
if (itemData.email === null) {
console.log("inside if = true");
$w('#email2').hide();
} else {
$w('#email2').show();
}
if (itemData.phone === null) {
console.log("inside if = true");
$w('#phone2').hide();
} else {
$w('#phone2').show();
}
function show () {
if ($w('#web').src === "")
$w('#web2').hide();
}
}); }); });
URL: https://elizabethjhay.wixsite.com/mysite/business-directory
Field keys for my data are: website, phone, email
Here is the code within the page
I took the code out completely just to test the editor. The editor is still crashing. I cached the page and I tested my site load on wix speed test. I am at 17s. What is going on? I don’t think it is just the code. Please help.
Contact Wix Support
https://support.wix.com/en/article/contacting-wix-support
https://support.wix.com/en/article/contacting-wix-by-phone-3491545
If you want immediate help, then you are best calling by phone.
In the meanwhile, simply try using another web browser, or close and clear the cache and cookies of the current browser and try again.
Hi Elizabeth. The function show seems redundant. More importantly it is missing a closing }.
I would move it outside of the $w.onReady() function.
Also since you are testing for truthiness of email and phone I suggest you move the assignment to $item(’#email’).link inside the else of the email test and the same for $item(‘#phone’).link.
Lastly what are $w(‘#email2’) & $w(’#phone2’)? Shouldn’t these be $item(’#email’) & $item(’#phone’) ?
So, I have updated the code quite a bit. Still getting the error. Originally I had text under my icons so I grouped the text and the icon to be email2 and phone 2.
Here is the update. When I add the hide and show is when I run into issues.
$w.onReady( () => {
$w("#dataset1").onReady( () => {
$w("#repeater1").onItemReady( ($item, itemData, index) => {
let theItem = itemData.companyName; itemData.address; itemData.website; itemData.email; itemData.phone;
$item("#company").text = itemData.companyName;
$item("#address").text = itemData.address;
$item("#email").link = 'mailto:' + itemData.email;
$item("#phone").link = 'tel:' + itemData.phone;
if (itemData.email === null) {
console.log("inside if = true");
$w('#email').hide();
} else {
$w('#email').show();
}
if (itemData.phone === null) {
console.log("inside if = true");
$w('#phone').hide();
} else {
$w('#phone').show();
}
});
} );
} );
I am still getting really slow editor issues
Sorry pasted wrong code update. I also still have web, but I connected that via the data set. I haven’t added the hide show for that.
$w.onReady( () => {
$w("#dataset1").onReady( () => {
$w("#repeater1").onItemReady( ($item, itemData, index) => {
let theItem = itemData.companyName; itemData.address; itemData.email; itemData.phone;
$item("#company").text = itemData.companyName;
$item("#address").text = itemData.address;
$item("#email").link = 'mailto:' + itemData.email;
$item("#phone").link = 'tel:' + itemData.phone;
if (itemData.email === null) {
$w('#email').hide();
} else {
$w('#email').show();
}
if (itemData.phone === null) {
$w('#phone').hide();
} else {
$w('#phone').show();
}
});
} );
} );
You also need to use $item in the conditionals that’s show and hide not $w 
Also open up the console and ctl click in the console area to open the developer tool menu.
Then click on inspect to see what errors are being generated during the load process.
Ok so Code issue solved! No errors in the console, but the editor and my load times are ridiculously slow still. It takes more than a minute to preview and I know it is not my browser or network as I have speed tested those and other sites are loading much quicker.
$w.onReady( () => {
$w("#dataset1").onReady( () => {
$w("#repeater1").onItemReady( ($item, itemData, index) => {
let theItem = itemData.companyName; itemData.address; itemData.email; itemData.phone; itemData.website;
$item("#company").text = itemData.companyName;
$item("#address").text = itemData.address;
$item("#email").link = 'mailto:' + itemData.email;
$item("#phone").link = 'tel:' + itemData.phone;
$item("#web").url = itemData.website;
if (itemData.email === null) {
$item("#email").hide();
} else {
$item("#email").show();
}
if (itemData.phone === null) {
$item("#phone").hide();
} else {
$item("#phone").show();
}
if (itemData.website === null) {
$item("#web").hide();
} else {
$item("#web").show();
}
});
} );
} );
Are your other pages loading slowly? What happens in a different browser ? What happens when you load a published page (that’s What counts)? It may be a browser issue as much as a wix backend. If you are using chrome try closing it and opening it again after closing all tabs. Sometimes the session cookies need to be flushed.
So I have tried it on another browser. This page is the problem. I am using both safari and chrome. I have cleared history/cache for both and I have run the Wix turbo speed test. The editor is equally slow to load on both.
Home page loads at 1.4s Cached
About page loads at 2.5s-2.8s Not Cached
Business directory 11.9s-13.2s Cached
I haven’t connected the premium settings to this site yet, but I don’t think that would be an issue.
Thanks for all you help! As always, you are a wonderful help Steve!
Maybe give this a try:
It could potentially solve your issue, and even if it doesn’t, you’ll notice overall connection improvements.
I don’t think it is my network. I have done the speedtest. I submitted this issue to the experts forum. I think it has to do with the repeater optimization. I’m thinking it has to do with the on ready function, but I don’t know where to start with that.
I tried it by the way. No change.
Update on this. I am now getting this error.
I also get as delayed as 26ms. So the code is effecting load speeds.
The DNS server thing was to see if the problem was the server your computer was accessing the internet through. 26ms is hardly noticeable, but it’s still odd for the amount of code you’ve posted here.
Is there any more code on that page? Do you have any data hooks? How large is your collection and does the dataset have any filters? Do you have any other repeaters or apps running on that page?
1 of 3:
Yeah. I previously stated that I did the DNS thing.
I added a search bar so yes there is some more code
Here it is in full
import wixData from 'wix-data';
$w.onReady( () => {
$w("#dataset1").onReady( () => {
$w("#repeater1").onItemReady( ($item, itemData, index) => {
let theItem = itemData.companyName; itemData.address; itemData.email; itemData.phone; itemData.website;
$item("#company").text = itemData.companyName;
$item("#address").text = itemData.address;
$item("#email").link = 'mailto:' + itemData.email;
$item("#phone").link = 'tel:' + itemData.phone;
$item("#web").url = itemData.website;
if (itemData.email === null) {
$item("#email").hide();
$item('#email2').hide();
} else {
$item("#email").show();
$item('#email2').show();
}
if (itemData.phone === null) {
$item("#phone").hide();
$item('#phone2').hide();
} else {
$item("#phone").show();
$item('#phone2').show();
}
if (itemData.website === null) {
$item("#web").hide();
$item('#web2').hide();
} else {
$item("#web").show();
$item('#web2').show();
}
});
});
});
export function searchName_keyPress(event) {
filter($w('#searchName').value);
let debounceTimer;
if (debounceTimer){
clearTimeout (debounceTimer);
debounceTimer=undefined;
}
debounceTimer = setTimeout (() => {
filter ($w('#searchName').value);
},200);
let lastFilterTitle;
function filter (title) {
if (lastFilterTitle !== title){}
$w('#dataset1').setFilter(wixData.filter().contains('companyName', title));
lastFilterTitle = title;
}
}
2 of 3:
I don’t have any hooks and I also don’t have other repeaters or apps running on the page.
The reason I am answering about amount last is because I wanted to show all 181 items. I believe this might be the culprit.
I played around with deleting the dataset and relinking it. It started to speed up the page load when the show was at 20 and then at 5. Not a huge speed up, but I noticed a difference.
My issue is my client is expecting to see all items in the database