For Developers: Widgets JS API events

Custom events

Use these events, if your want to custom our app with the help of JS. If you still have any questions after reading the article, don’t hesitate to address them to feedback@searchanise.io

Searchanise.Loaded

Main event is triggered right after Searchanise is loaded. To make sure that the correct jQuery version is used, other custom event Listeners should be inside this one.

Code

document.addEventListener('Searchanise.Loaded', function () {
         (function ($) {
                        
         })(window.Searchanise.$);
});

Searchanise.AutocompleteUpdated

Allows to modify Instant Search Widget content only.

Code

$(document).on('Searchanise.AutocompleteUpdated', function(event, input, container) {
});

When

• Instant Search Widget finishes its content rendering.

Parameters

event — jQuery event, see the official guide
input — jQuery object of search input field handled user query
container — jQuery object of container for Instant Search Widget

Searchanise.ResultsUpdated

Allows to modify Search Results Widget content only.

Code

$(document).on('Searchanise.ResultsUpdated', function(event, container) {
});

When

• Search Results Widget finishes its content rendering
• Option swatches changed within Search Results Widget
• Browser screen resizing

Parameters

event — jQuery event, see the official guide
container — jQuery object of container for Search Result Widget

Searchanise.RecommendationUpdated

Allows to modify Recommendation Widget block content only.

Code

$(document).on('Searchanise.RecommendationUpdated', function(event, container) {
});

When

• Recommendation widget block finishes its content rendering. Please note that multiple widgets on the same page fire this custom event multiple times.

Parameters

event — jQuery event, see the official guide
container — jQuery object of container for Recommendation widget block

Searchanise.DataRequestEnd

Allows to post-modify data for all type of widgets.

Code

$(document).on('Searchanise.DataRequestEnd', function(event, type, params, data) {
});

When

• Successful response of AJAX search query (for Instant Search Widget and Search Results Widget)
• Successful response for Recommendation Widget block.

Parameters

event — jQuery event, see the official guide
type — widget type triggered the event. Possible values:
o autocomplete — Instant Search Widget
o results — Search Result Widget
o recommendation — Recommendation widget block
params — search query parameters
data — received data

Searchanise.DataRequestBefore

Allows to pre-modify request parameters for all type of widgets.

Code

$(document).on('Searchanise.DataRequestBefore', function(event, type, params) {
});

When

• Before sending AJAX search query (for Instant Search Widget and Search Results Widget)
• Before sending query for Recommendation Widget block

Parameters

event — jQuery event, see the official guide
type — widget type triggered the event. Possible values:
o autocomplete — Instant Search Widget
o results — Search Result Widget
o recommendation — Recommendation widget block
params — search query parameters

Searchanise.AddToCartSuccess

Allows to add extra logic on Add to cart for widgets.

Code

$(document).on('Searchanise.AddToCartSuccess', function(event, add_to_cart_id, product) {
});

When

• Product successfully added to cart from Search Result Widgets on Shopify, Magento and Magento2
• Product successfully added to cart from Searchanise Quick View on Shopify and BigCommerce
• Product successfully added to cart from Recommendation Widget block for Shopify and Magento

Parameters

event — jQuery event, see the official guide
add_to_cart_id — variant ID for Shopify or ID of product added to cart for other platforms
product — product data retrieved from Searchanise API

Searchanise.QuickViewUpdated

Allows to modify Quick View content only.

Code

$(document).on('Searchanise.QuickViewUpdated', function(event, container, item) {
});

When

• Pop-up successfully opened by clicking the Quick View button
• Variant changed within Quick View pop-up

Parameters

event — jQuery event, see the official guide
container — jQuery object of container for Quick View pop-up
item — data of the selected product retrieved from Searchanise API

Updated on July 13, 2023

Was this article helpful?

Related Articles

Back to top