Hi! I’ve implemented a viewing and an image resize system to my site for my repeater. In the preview mode, the code works perfectly. But, in the published version, once I view the website, the velo code doesn’t seem to work for the first three times. Once I reload the page three times approx, the code starts to work, yet it still fails many times later on.
Does anyone know what could it be causing such issues?
Thanks in advance.
Preview image (Works perfectly) :
Published mode (Doesn t work) :
Code:
$w ( “#image” ). fitMode = “fixedWidth” ;
import wixData from ‘wix-data’ ;
$w . onReady (() => {
$w ( "#popularityDropdown" ). onChange (() => {
**let** sortDrop = $w ( "#popularityDropdown" ). value ;
**if** ( sortDrop === "Most popular" ) {
$w ( "#dynamicDataset" ). setSort ( wixData . sort (). descending ( "pageView" ))
} **else** {
$w ( "#dynamicDataset" ). setSort ( wixData . sort (). ascending ( "pageView" ))
}
})
});
$w ( “#listRepeater” ). onItemReady (( $item , itemData ) => {
$item ( “#viewCounter” ). text = String ( formatView ( itemData . pageView ));
});
//FORMAT THE VIEWS PER ZERO
function formatView ( view ) {
if ( view > 999 && view < 1000000 ) {
return ${( view / 1000 ). toFixed ( 0 )} K
;
} else if ( view >= 1000000 && view < 1000000000 ) {
return ${( view / 1000000 ). toFixed ( 0 )} M
;
} else if ( view >= 1000000000 ) {
return ${( view / 1000000000 ). toFixed ( 0 )} B
;
} else if ( view < 900 ) {
return view ;
}
}