Loyalty & Rewards - Javascript / Events References

Should you require to do further modification to the Rewards widget which involves Javascript, you may have to use Stamped.io's listening event to run the codes after the widget is loaded.


In This Guide


Adding The Listening Event Code

Add this JS function for listening to events fired by Stamped.io

function addEventListenerStamped(el, eventName, handler) {
if (el.addEventListener) { el.addEventListener(eventName, handler); }
else { el.attachEvent('on' + eventName, function () { handler.call(el); }); }
}

// Listening for event
addEventListenerStamped(document, '##replaceWithEventName##', function(e) {
'##replaceWithFunction##'
});

// Example
// Listening for launcher loaded event
addEventListenerStamped(document, 'stamped:launcher:loaded', function(e) {
StampedFn.toggleRewardsModal();
});

Events

Event Name Fired When
stamped:launcher:loaded The launcher loaded
stamped:widget:rewards-earnings:loaded Page Earnings widget loaded

JS Methods

Script Function
StampedFn.toggleRewardsModal(); Open/close the Launcher
StampedFn.loadLauncherView('view-referrals-email');
Load the "Referrals" card view.
StampedFn.loadLauncherView('view-spendings');
Load the "Sendings" card view.
StampedFn.loadLauncherView('view-earnings');
Load the "Earnings" card view.
StampedFn.loadLauncherView('view-your-rewards');
Call this method to load the "Your Rewards" card view.