Hi, have searched and haven’t found any reference to this, so apologies if I’ve missed something.
I am collecting the Product object from the current page in the page’s OnReady() event, feeding the price of it into a HTMLComponent on the page via the Messaging, and then updating an element within the HTMLComponent’s frame with the price. (The end result won’t be just that, but it’s a convenient way of making sure everything is passed through as expected while building)
It’s working as expected with loading a fresh page coming in from the category page to the product. However, I have the Navigation set to being Visible, and use of the Next/Previous buttons to go from product to product doesn’t appear to call $w()OnReady to then be able to repopulate it with the current product’s data. I have called the debugger in the OnReady and it breaks there as expected on the 1st product load, but doesn’t subsequently when using the navigation.
Am guessing I have missed something obvious to more experienced Wix/Velo users, another event that isn’t showing up when I search maybe?
code am using is below, in case that sheds any light to more experienced eyes:
$w . onReady ( function () {
debugger ;
// Write your Javascript code here using the Velo framework API
//console.log(“start”);
$w ( ‘#productPage1’ ). getProduct ()
. then (( product ) => {
let pageproductprice = product . discountedPrice . toFixed ( 2 );
$w ( "#htmlCompPP" ). scrolling = "no"
//console.log("sending msg, product price = " + pageproductprice)
console . log ( "pageproductprice " + pageproductprice );
// send message to the HTML element
$w ( "#htmlCompPP" ). postMessage ( pageproductprice );
})
. **catch** (( error ) => {
console . log ( "oops" );
});
});
content of the HTMLComponent:
.label { font-family: 'Arial'; } HTML Label