Adding comma to price

@tiaan Thanks, Tiaan… here’s what I did to get it to work. It’s not perfect, but it works (kinda)…

$w.onReady( function () {
$w(“#dynamicDataset”).onReady(() => {
console.log(‘ready’)
populateFormattedPrice();
} );

$w(“#dynamicDataset”).onCurrentIndexChanged( (index) => {
console.log(‘index has changed’)
populateNewFormattedPrice();
} );

} );

function populateFormattedPrice() {
$w(“#dynamicDataset”).onReady(() => {
$w(‘#repeater1’).onItemReady( ($item, itemData, index) => {
const numberWithCommas = (x) => {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, “,”);
}
$item(‘#priceText’).text = “$” + numberWithCommas(parseInt($item(‘#priceText’).text, 10));
} );
});
}

function populateNewFormattedPrice() {
$w(“#dynamicDataset”).onReady(() => {
$w(‘#repeater1’).forEachItem( ($newItem, itemData, index) => {
console.log(‘new item ready’)
const newNumberWithCommas = (x) => {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, “,”);
}
$newItem(‘#priceText’).text = “$” + newNumberWithCommas(parseInt($newItem(‘#priceText’).text, 10));
});
});
}