Events

View the JS SDK life cycle events.

loaded

This event may be helpful if you want to write (or include) javascript code before SDK will be loaded by a browser and make some actions when SDK will be available.

/**
 * @param {string} event
 * @param {function} callback
 */
window.addEventListener("langshop:loaded", function() {

    /**
     * LangShopSDK object is defined in the global scope and available now
     *
     * @param {string} event
     * @param {function} callback
     */
    LangShopSDK.on("ready", function() {
        ...
    });
});

beforeSwitchersCreated

LangShop starts to create languages and currencies switchers immediately after "DOMContentLoaded" window event. Subscribe to this event if you need to know when SDK begins initialization.

/**
 * @param {string} event
 * @param {function} callback
 */
LangShopSDK.on("beforeSwitchersCreated", function() {
    ...
});

beforeSwitcherCreated

This event will be triggered each time when SDK ready to insert switcher into the DOM per each switcher.

/**
 * @param {string} event
 * @param {function} callback
 *
 * @callback
 * @param {HTMLElement} container
 * @param {string} type, one of: "languages", "currencies"
 */
LangShopSDK.on("beforeSwitcherCreated", function(container, type) {
    ...
});

afterSwitcherCreated

Triggered each time when new language or currency switcher inserted into the DOM.

/**
 * @param {string} event
 * @param {function} callback
 *
 * @callback
 * @param {HTMLElement} container
 * @param {string} type, one of: "languages", "currencies"
 */
LangShopSDK.on("afterSwitcherCreated", function(container, type) {
    ...
});

afterSwitchersCreated

Subscribe to this event if you need to know when all languages and currencies switchers will be created.

/**
 * @param {string} event
 * @param {function} callback
 */
LangShopSDK.on("afterSwitchersCreated", function() {
    ...
});

ready

The "ready" event needed to indicate when LangShop successfully initialized and ready for user actions.

/**
 * @param {string} event
 * @param {function} callback
 */
LangShopSDK.on("ready", function() {
    ...
});

beforeLanguageSwitched

Triggered when SDK starts the language switching process.

/**
 * @param {string} event
 * @param {function} callback
 *
 * @callback
 * @param {string} code
 */
LangShopSDK.on("beforeLanguageSwitched", function(code) {
    ...
});

beforeCurrencySwitched

Triggered when SDK starts the currency switching process.

/**
 * @param {string} event
 * @param {function} callback
 *
 * @callback
 * @param {string} code
 */
LangShopSDK.on("beforeCurrencySwitched", function(code) {
    ...
});

dropdownSwitcherOpened

This event indicates when the user opens dropdown switcher.

/**
 * @param {string} event
 * @param {function} callback
 *
 * @callback
 * @param {HTMLElement} container
 * @param {string} type, one of: "languages", "currencies"
 */
LangShopSDK.on("dropdownSwitcherOpened", function(container, type) {
    ...
});

dropdownSwitcherClosed

The event triggered when the dropdown switcher changes state from open to closed.

/**
 * @param {string} event
 * @param {function} callback
 *
 * @callback
 * @param {HTMLElement} container
 * @param {string} type, one of: "languages", "currencies"
 */
LangShopSDK.on("dropdownSwitcherClosed", function(container, type) {
    ...
});

Report incorrect information

Still Have Questions?

Our customer care team is here for you!

Contact Us