Introduction
Starting with v3 of Findmine's hosted JavaScript widget platform, customers can define callbacks to be made when specific widget events occur.
You can configure event callbacks in the FindMine object as optional JavaScript functions that are called by the FindMine widgets when, for example, a user clicks on a look item. Event callbacks are useful for a number of purposes, such as triggering a 3rd party analytics event or layout adjustments.
Event Handlers
Event handlers are as follows:
*onFinish*
- Findmine JavaScript finished loading*onPreviousLook*
and *onNextLook*
- User advanced the carousel (in a multi-look carousel widget configuration)*onItemClick*
- User clicked on a featured item in a lookNote: Some event handlers have an e
parameter, which gives you access to the native browser event object. See the installation section for example code.
Installation
The snippet shown below highlights the event callbacks for FindMine widgets. Each callback is optional and independent from one another.
window.onload = **function**() {
window.FindMine.match({
// Placeholder product
application: '123',
product_id: 'YXZ',
return_pdp_item: **true**,
event_handlers: {
onItemClick: **function**(e){ console.log('Item Clicked', e) },
onPreviousLook: **function**(e){ console.log('Previous Look', e) },
onNextLook: **function**(e){ console.log('Next Look', e) },
onFinish: **function**(){ console.log('FindMine Loaded') }
}
});
};