onPropsChanged( )


Adds an event handler that runs when the value of a widget property is changed.

A widget receives an onPropsChanged event when one or more of its properties is changed via its API.

Method Declaration
Copy
function onPropsChanged(handler: function): any;
Method Parameters
handlerfunctionRequired

handler(oldProps: object, newProps: object): void The name of the function or the function expression to run when the value of a widget property is changed.

Returns
Return Type:any
Load updated data when a widget's property is changed
JavaScript
$widget.onPropsChanged((oldProps, newProps) => { loadProductData(newProps.productId); loadCustomerData(newProps.customerId); });
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?