Maybe someone could help me a bit. I have populated a repeater to my collection via a dataset. I am using the following code to calculate the deviation from average of the results. However, when I need to move the pagination a few pages back and forth before the results (e.g $item( ’ #labHeight5 ’ ).value ) are updated. Why is that? Thanks! Link to page: https://www.nordicelysium.com/members
// For full API documentation, including code examples, visit Velo API Reference - Wix.com
import wixData from ‘wix-data’ ;
import wixUsers from ‘wix-users’ ;
$w.onReady( function () {
//TODO: write your page related code here…
wixData.aggregate( “elysiumData” )
.avg( “height” )
.avg( “weight” )
.avg( “bmi” )
.avg( “muscleMass” )
.avg( “bodyFat” )
.avg( “visceralFat” )
.avg( “saturation” )
.avg( “hsCrp” )
.avg( “hbA1C” )
.avg( “mindScore” )
.avg( “trainScore” )
.avg( “alcoholScore” )
.avg( “smokeScore” )
.avg( “foodScore” )
.avg( “bodyScore” )
.avg( “rateYou1” )
.avg( “rateYou2” )
.avg( “rateYou3” )
.avg( “cardiovascularDisease” )
.avg( “cancer” )
.avg( “diabetesMellitus” )
.avg( “respiratoryDisease” )
.avg( “brain” )
.avg( “infection” )
.avg( “drugAbuse” )
.avg( “accidents” )
.avg( “suicide” )
.avg( “bioAge” )
.avg( “bodyAge” )
.avg( “mentalAge” )
.avg( “projectedLifespan” )
.avg( “projectedLifecycle” )
.avg( “statHealth” )
.avg( “statPerformance” )
.avg( “statStress” )
.avg( “bioDefense” )
.run()
.then((results) => {
let heightAvg = results.items[ 0 ].heightAvg;
let weightAvg = results.items[ 0 ].weightAvg;
let bmiAvg = results.items[ 0 ].bmiAvg;
let muscleMassAvg = results.items[ 0 ].muscleMassAvg;
let bodyFatAvg = results.items[ 0 ].bodyFatAvg;
let visceralFatAvg = results.items[ 0 ].visceralFatAvg;
let saturationAvg = results.items[ 0 ].saturationAvg;
let hsCrpAvg = results.items[ 0 ].hsCrpAvg;
let hbA1CAvg = results.items[ 0 ].hbA1CAvg;
let mindScoreAvg = results.items[ 0 ].mindScoreAvg;
let trainScoreAvg = results.items[ 0 ].trainScoreAvg;
let alcoholScoreAvg = results.items[ 0 ].alcoholScoreAvg;
let smokeScoreAvg = results.items[ 0 ].smokeScoreAvg;
let foodScoreAvg = results.items[ 0 ].foodScoreAvg;
let bodyScoreAvg = results.items[ 0 ].bodyScoreAvg;
let rateYou1Avg = results.items[ 0 ].rateYou1Avg;
let rateYou2Avg = results.items[ 0 ].rateYou2Avg;
let rateYou3Avg = results.items[ 0 ].rateYou3Avg;
let cardiovascularDiseaseAvg = results.items[ 0 ].cardiovascularDiseaseAvg;
let cancerAvg = results.items[ 0 ].cancerAvg;
let diabetesMellitusAvg = results.items[ 0 ].diabetesMellitusAvg;
let respiratoryDiseaseAvg = results.items[ 0 ].respiratoryDiseaseAvg;
let brainAvg = results.items[ 0 ].brainAvg;
let infectionAvg = results.items[ 0 ].infectionAvg;
let drugAbuseAvg = results.items[ 0 ].drugAbuseAvg;
let accidentsAvg = results.items[ 0 ].accidentsAvg;
let suicideAvg = results.items[ 0 ].suicideAvg;
let bioAgeAvg = results.items[ 0 ].bioAgeAvg;
let bodyAgeAvg = results.items[ 0 ].bodyAgeAvg;
let mentalAgeAvg = results.items[ 0 ].mentalAgeAvg;
let projectedLifespanAvg = results.items[ 0 ].projectedLifespanAvg;
let projectedLifecycleAvg = results.items[ 0 ].projectedLifecycleAvg;
let statHealthAvg = results.items[ 0 ].statHealthAvg;
let statPerformanceAvg = results.items[ 0 ].statPerformanceAvg;
let statStressAvg = results.items[ 0 ].statStressAvg;
let bioDefenseAvg = results.items[ 0 ].bioDefenseAvg;
//$w(‘#labHeight5’).value = ($w(‘#labHeight2’).text / heightAvg) * 100
$w( ‘#labWeight5’ ).value = ($w( ‘#labWeight2’ ).text / weightAvg) * 100 ;
$w( ‘#labBmi5’ ).value = ($w( ‘#labBmi2’ ).text / bmiAvg) * 100 ;
$w( ‘#labMuscle5’ ).value = ($w( ‘#labMuscle2’ ).text / muscleMassAvg) * 100 ;
$w( ‘#labFat5’ ).value = ($w( ‘#labFat2’ ).text / bodyFatAvg) * 100 ;
$w( ‘#labVisceralFat5’ ).value = ($w( ‘#labVisceralFat2’ ).text / visceralFatAvg) * 100 ;
$w( ‘#labSat5’ ).value = ($w( ‘#labSat2’ ).text / saturationAvg) * 100 ;
$w( ‘#labHscrp5’ ).value = ($w( ‘#labHscrp2’ ).text / hsCrpAvg) * 100 ;
$w( ‘#labHba1c5’ ).value = ($w( ‘#labHba1c2’ ).text / hbA1CAvg) * 100 ;
$w( ‘#psiMind5’ ).value = ($w( ‘#psiMind2’ ).text / mindScoreAvg) * 100 ;
$w( ‘#psiActivity5’ ).value = ($w( ‘#psiActivity2’ ).text / trainScoreAvg) * 100 ;
$w( ‘#psiAlcohol5’ ).value = ($w( ‘#psiAlcohol2’ ).text / alcoholScoreAvg) * 100 ;
$w( ‘#psiSmoking5’ ).value = ($w( ‘#psiSmoking2’ ).text / smokeScoreAvg) * 100 ;
$w( ‘#psiDiet5’ ).value = ($w( ‘#psiDiet2’ ).text / foodScoreAvg) * 100 ;
$w( ‘#psiHealth5’ ).value = ($w( ‘#psiHealth2’ ).text / bodyScoreAvg) * 100 ;
$w( ‘#psiSelfHealth5’ ).value = ($w( ‘#psiSelfHealth2’ ).text / rateYou1Avg) * 100 ;
$w( ‘#psiSelfPerformance5’ ).value = ($w( ‘#psiSelfPerformance2’ ).text / rateYou2Avg) * 100 ;
$w( ‘#psiSelfStress5’ ).value = ($w( ‘#psiSelfStress2’ ).text / rateYou3Avg) * 100 ;
$w( ‘#lifestyleCvd5’ ).value = ($w( ‘#lifestyleCvd2’ ).text / cardiovascularDiseaseAvg) * 100 ;
$w( ‘#lifestyleCancer5’ ).value = ($w( ‘#lifestyleCancer2’ ).text / cancerAvg) * 100 ;
$w( ‘#lifestyleDm5’ ).value = ($w( ‘#lifestyleDm2’ ).text / diabetesMellitusAvg) * 100 ;
$w( ‘#lifestyleLung5’ ).value = ($w( ‘#lifestyleLung2’ ).text / respiratoryDiseaseAvg) * 100 ;
$w( ‘#lifestyleNeuro5’ ).value = ($w( ‘#lifestyleNeuro2’ ).text / brainAvg) * 100 ;
$w( ‘#lifestyleInfection5’ ).value = ($w( ‘#lifestyleInfection2’ ).text / infectionAvg) * 100 ;
$w( ‘#lifestyleDrug5’ ).value = ($w( ‘#lifestyleDrug2’ ).text / drugAbuseAvg) * 100 ;
$w( ‘#lifestyleAccidents5’ ).value = ($w( ‘#lifestyleAccidents2’ ).text / accidentsAvg) * 100 ;
$w( ‘#lifestyleSuicide5’ ).value = ($w( ‘#lifestyleSuicide2’ ).text / suicideAvg) * 100 ;
$w( ‘#statBioage5’ ).value = ($w( ‘#statBioage2’ ).text / bioAgeAvg) * 100 ;
$w( ‘#statBody5’ ).value = ($w( ‘#statBody2’ ).text / bodyAgeAvg) * 100 ;
$w( ‘#statMental5’ ).value = ($w( ‘#statMental2’ ).text / mentalAgeAvg) * 100 ;
$w( ‘#statLifespan5’ ).value = ($w( ‘#statLifespan2’ ).text / projectedLifespanAvg) * 100 ;
$w( ‘#statCycle5’ ).value = ($w( ‘#statCycle2’ ).text / projectedLifecycleAvg) * 100 ;
$w( ‘#statHealth5’ ).value = ($w( ‘#statHealth2’ ).text / statHealthAvg) * 100 ;
$w( ‘#statPerformance5’ ).value = ($w( ‘#statPerformance2’ ).text / statPerformanceAvg) * 100 ;
$w( ‘#statStress5’ ).value = ($w( ‘#statStress2’ ).text / statStressAvg) * 100 ;
$w( ‘#statBiodefense5’ ).value = ($w( ‘#statBiodefense2’ ).text / bioDefenseAvg) * 100 ;
$w( “#elysiumData1” ).onReady(() => {
$w( ‘#labHeight5’ ).value = ($w( ‘#labHeight2’ ).text / heightAvg) * 100 ;
$w( “#pagination1” ).onClick((event, $w) => {
let $item = $w.at(event.context);
$item( ‘#labHeight5’ ).value = ($item( ‘#labHeight2’ ).text / heightAvg) * 100 ;
})
});
})
});