Popup widget view changed
This event is triggered when the view of the popup widget is changed. It provides details about the new view that is displayed.
Event details
When the popUpWidgetViewChanged event is triggered, the received event.detail object includes the following properties:
PopUpWidgetViewChangedSdkEventProperties
readonly type"popUpWidgetViewChanged"- Event type identifier
readonly viewPopUpWidgetViewsType- The name of the new view that is displayed in the popup widget
Usage example
Before listening for the popupWidgetViewChanged event, ensure the SDK and the Rewards module are ready:
function subscribeToPopupWidgetViewChanged() {
const eventName = window.gw.sdk.rewards.events.POPUP_WIDGET_VIEW_CHANGED;
window.gw.sdk.on(eventName, (event) => {
console.log(event.detail);
});
}
function onSdkReady() {
const moduleName = window.gw.sdk.common.constants.modules.REWARDS;
window.gw.sdk.runIfModuleReady(moduleName, () => {
subscribeToPopupWidgetViewChanged();
});
}
if (window.gw && window.gw.sdk) {
onSdkReady();
} else {
document.addEventListener("gwSdkReady", onSdkReady);
}
// Example output:
// {type: 'popupWidgetViewChanged', view: 'home'}
This code ensures the SDK and the Rewards module are ready before setting up the event listener, allowing you to respond when the popup widget view changes and access the relevant details.
Possible view values
The view property can be one of the following values:
home— Home view of the popup widgetways_to_earn— Ways to earn points viewways_to_redeem— Ways to redeem points viewreferral— Referral program viewvip_tiers— VIP tiers view