Should you require to do further modification to the main widget which involves Javascript, you may have to use Stamped'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
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) { console.log(e); }); // Example // Listening for reviews widget loaded event addEventListenerStamped(document, 'stamped:reviews:loaded', function(e) { console.log(e); });
Events
Event Name | Fired When |
stamped:reviews:submitted | Review is submitted through the widget form |
stamped:reviews:loaded | Reviews main widget loaded |
stamped:questions:loaded | Q&A section loaded in main widget |
stamped:ugcmodal:paged stamped:ugcmodal:open | Pop-up modal loaded/on page change |
stamped:photo:uploaded | Photo/video uploaded on main widget submission form |
JS Methods
Script | Function |
StampedFn.reloadUGC(); | Reloads all widget on the page including Main Widgets and Display Widgets (example use-case: change the data-product-id attribute value in main widget and call this method to reload the reviews) |
StampedFn.loadBadges(); | Reloads the star ratings widget with classname ".stamped-product-reviews-badge" |
StampedFn.toggleForm('review') | Toggle the visibility of the review form |
StampedFn.toggleForm('question') |
Toggle the visibility of the question form |