Hi,
I’m working on a website and I’ve created a repeater, and each repeater has a specific rating according to each dynamic page that have a specific rating
And I follow the Rating of users and it works on the dynamic pages
But when I worked on repeater it works but it work on the first one and the rating of the first one is applying to the all repeaters
Just like that:
I write this code and it’s a part of Rating of users :
//-------------Imports-------------//
import wixData from 'wix-data';
import wixWindow from 'wix-window';
//-------------Global Variables-------------//
// Current profesores.
let profesores;
//-------------Page Setup-------------//
$w.onReady(async function () {
// Set the global profesores variable to the currently displayed profesores.
profesores = await $w('#dynamicDataset').getCurrentItem();
// Load the current profesores's reviews using the initReviews() function.
initReviews();
});
// Loads the current profesores's reviews.
async function initReviews() {
// Filter the "Reviews" dataset to contain only the reviews on the currently displayed profesores.
await $w('#Reviews').setFilter(wixData.filter().eq('profesoresId', profesores._id));
// Load the current profesores's statistics using the loadStatistics() function.
loadStatistics();
}
// Load the current profesores's statistics.
async function loadStatistics() {
// Get the statistics data based on the current profesores's ID.
const stats = await wixData.get('review-stats', profesores._id);
// If statistics data for the profesores was found:
if (stats) {
// Compute the profesores's average rating by dividing the total points by the number of ratings.
let avgRating = (Math.round(stats.rating * 10 / stats.count) / 10);
// Compute the percentage of reviewers that recommend the profesores.
let percentRecommended = Math.round(stats.recommended / stats.count * 100);
// Get the ratings element.
let ratings = $w('#generalRatings');
// Set the ratings element's average rating to the value calculated above.
ratings.rating = avgRating;
// Set the ratings element's number of ratings to the count value from the statistics data.
ratings.numRatings = stats.count;
// Set the text for the recommended percentage element.
// Show the ratings element.
$w('#generalRatings').show();
// If there is no statistics data for the profesores:
}
} the ratings element.
$w('#generalRatings').show();
// If there is no statistics data for the profesores:
}
}
This is the page in the editor mode
Thank you for your respond to my forums
Eyad