API Reference for Content Widgets

Onsite Widgets JavaScript API Reference

Inline Tiles API

Events

The following events are available in Waterfall, Carousel, Gallery, Feed, Grid, Masonry, Nightfall, and all future widgets.

$(document).on('widget:ready', function (e, instance) {
    instance
        .on('init', function (e, instance) {
            console.log(e.type, instance);
        })
        .on('load', function (e, listData) {
            console.log(e.type, listData);
        })
        .on('beforeRender', function (e, $appendRoot, listData) {
            console.log(e.type, $appendRoot, listData);
        })
        .on('beforeIterate', function (e, tileData, tileId) {
            console.log(e.type, tileData, tileId);
        })
        .on('beforeAppend', function (e, $tile, tileData, $appendRoot) {
            console.log(e.type, $tile, tileData, $appendRoot);
        })
        .on('iterate', function (e, tileData, tileHtml) {
            console.log(e.type, $tile, tileData, $appendRoot);
        })
        .on('append', function (e, $tile, tileData, $appendRoot) {
            console.log(e.type, $tile, tileData, $appendRoot);
        })
        .on('render', function (e, $appendRoot, listData) {
            console.log(e.type, $appendRoot, listData);
        });
});

Legacy Callbacks

This section is only for Waterfall and Carousel widgets.

Callbacks.prototype.onCompleteJsonToHtml = function ($tile, tileData) {
    return $tile; // required, don't remove
};

Translation Strings

You can modify or translate Widget texts by accessing window.Strings global variable. The following strings are only useful on the Waterfall, Grid, Masonry, Quadrant, Feed, and Nightfall widgets.

Strings.load_more = 'Load more content';
Strings.loading = 'Loading...';
Strings.scroll_end = 'There is no more content to be displayed.'; // Waterfall widget only
Strings.voting_message = 'A vote has already been registered from this IP address.';

Global Widget Events API

The following Inline Tiles API are only available in Waterfall, Carousel, and Gallery widgets

You can access all the following events and methods via the window.Stackla.WidgetManager global variable.

Events

You can track user interactions by subscribing to Widget events.

Example Usage (for both Event and Methods)

Stackla.WidgetManager.on('tileExpand', function (e, data) {
    // Maybe you need to filter when you have multiple widgets on the same page.
    if (data.widgetId === 9999) {
        // do something...
    }
});

Note: To avoid manually checking the existence of the Stackla.WidgetManager global variable we recommend you use the Expanded Tile Code Editor in our Nosto Admin Portal.

Available Events

beforeExpandedTileClose Triggered before the Expanded Tile closes

  • e

  • data.el

  • data.tileData

  • data.widgetId

Methods

You can update Widget content by invoking the following methods.

Example Usage

Stackla.WidgetManager.search(widgetId, keyword)

Note: To avoid manually checking the existence of the Stackla.WidgetManager global variable we recommend you use the Expanded Tile Code Editor in our Nosto Admin Portal.

Available Methods

More Details

Take a look at our How to use “Filter and search” in a Widget article for more examples.

Looking for some help with CSS widget customisations? Check out our CSS guides for styling the Waterfall Widget, Carousel Widget, as well as the Widget Expanded Tile.