So, the website seems fine in the mobile simulation, however when I test it on my smartphone, the site is not able to open the lightboxes from the associated buttons. The repeater I’m using for the comments and reviews section I built loads fine at first but defaults to the placeholder text in a couple of seconds. Need help. I’m new to Corvid. The elements are working absolutely fine on the desktop version.
Here’s the code for the product-page:
It’s a bit messy right, since I’ve pieced it together from multiple resources and my own amateur judgement but it seems to work. I wanted the reviews to be editable.
The website is www.printpourri. com
import wixData from 'wix-data';
import wixUsers from 'wix-users';
import wixWindow from 'wix-window';
import wixLocation from 'wix-location';
let product; let commentid;
$w.onReady(async function () {
product = await $w('#productPage1').getProduct();
initReviews();
});
async function initReviews() {
await $w('#dataset1').setFilter(wixData.filter().eq('id', product._id));
if ($w('#dataset1').getTotalCount() > 3) {$w('#button11').expand()}
else if ($w('#dataset1').getTotalCount()< 1) {$w('#text34').show()}
else {$w('#button11').collapse()}
showReviews();
loadStatistics();
}
async function loadStatistics() {
const stats = await wixData.get('Review-Stats', product._id);
if (stats) {
let avgRating = (Math.round(stats.rating * 10 / stats.count) / 10);
let ratings = $w('#ratingsDisplay2');
ratings.rating = avgRating;
ratings.numRatings = stats.count;
$w('#ratingsDisplay2').show();
} else {$w('#ratingsDisplay2').hide();
}
}
export function repeater1_itemReady($w, itemData, index) {
if(itemData.userid===wixUsers.currentUser.id) {
$w('#edit').expand();
$w('#delete').expand();
}
if (itemData.reviewerName) {
$w('#text29').text = itemData.reviewerName;
$w('#text29').expand();
}
if (itemData.reviewerReview) {
$w('#text31').text = itemData.reviewerReview;
$w('#text31').expand();
}
if (itemData.reviewerReview==="") {
$w('#text31').hide();
}
if (itemData.reviewImage) {
$w('#reviewImage').src = itemData.reviewImage;
$w('#reviewImage').expand();}
$w('#ratingsDisplay1').rating = itemData.rating;
let date = itemData._createdDate;
$w('#text33').text = date.toLocaleString("en-IN");
}
export function showReviews() {
if ($w('#dataset1').getTotalCount() > 0) {
$w('#repeater1').expand();
$w('#text34').hide();
} else {
$w('#repeater1').collapse();
}
}
export async function button8_click(event) {
if (wixUsers.currentUser.loggedIn) {
const dataForLightbox = {
userid: wixUsers.currentUser.id,
productId: product._id
};
let result = await wixWindow.openLightbox('Welcome (Jazzy)', dataForLightbox);
initReviews();
}
else {
wixUsers.promptLogin()
}
//Add your code for this event here:
}
export function button11_click(event, $w) {
$w('#dataset1').loadMore()();
}
export function reviewImage_click(event,$w) {
wixWindow.openLightbox('ProductImage', $w('#dataset1').getCurrentItem())
}
export async function edit_click(event, Sw) {
commentid = event.context.itemId;
let res=await wixWindow.openLightbox('Commentchange', commentid)
.then( () => {
wixLocation.to(wixLocation.url);
initReviews();
})}
export async function delete_click(event,$w) {
commentid = event.context.itemId;
wixData.remove("Reviews", commentid);
let delstat = await wixData.get('Review-Stats',product._id);
if (delstat) {let com = await wixData.get('Reviews', commentid);
delstat.rating += -com.rating;
delstat.count+=-1;
wixData.update('Review-Stats', delstat)
return wixLocation.to(wixLocation.url);
}
else
{return 5}
}