Allows the worker component to listen to events that happen in the editor or website.
SDK Version: SDK 1.11.0 - 1.96.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Worker
Make sure to register event listeners when the document loads, since previous listeners might be invalidated when we load your app.
Syntax:
Parameters:
Name | Type | Description |
---|---|---|
eventName (required) | Wix.Events | Unique event identifier, listed in the table below |
callback (required) | Function | A callback function that is called by the SDK once an event occurs. |
The events that you can currently listen to are:
Event | Event Data | Description |
---|---|---|
COMPONENT_DELETED | {} | Issued when the user deletes a site component. Note: This event is only sent to the component that was deleted, so use the Wix.PubSub.publish method to alert other site components in your app about this event. For worker components, use Wix.Worker.PubSub.publish. Availability: Since 1.13.0 |
DEVICE_TYPE_CHANGED | { deviceType: 'desktop' or 'mobile' } | Issued when the user switches between the desktop editor and mobile editor. Availability: Since 1.45.0 |
EDIT_MODE_CHANGE | {editMode: 'editor' or 'preview'} | Issued when a user toggles between preview and edit mode in the editor. Availability: Since 1.11.0 |
INSTANCE_CHANGED | {instance: instanceValue} | Issued when a component in your app called Wix.revalidateSession in the live site. Availability: Since 1.96.0 |
KEY_DOWN | {charCode:0, keyCode:39} | Issued when the user presses one of these keys on the keyboard: left/right arrows, esc, enter, space bar. Availability: Since 1.76.0 |
KEY_UP | {charCode:0, keyCode:39} | Issued when the user presses one of these keys on the keyboard: left/right arrows, esc, enter, space bar. Availability: Since 1.76.0 |
MEMBER_DETAILS_UPDATED | For example: "attributes": {"name": "John Doe", "firstName": "John", "lastName": "Doe", "imageUrl": "https://myImage.jpg", "nickname": "Johnny "}} | Issued when a member changes their personal details. Availability: Since 1.89.0 |
PAGE_NAVIGATION | {"toPage": "Page1", "fromPage": "Page2"} | Issued on any page navigation in the website. Availability: Since 1.25.0 |
PAGE_NAVIGATION_IN | {"toPage": "Page1", "fromPage": "Page2"} | Issued on any page in navigation in the website. This event is a utility event on top of the PAGE_NAVIGATION event. Availability: Since 1.25.0 |
PAGE_NAVIGATION_OUT | {"toPage": "Page1", "fromPage": "Page2"} | Issued on any page out navigation in the website. This event is a utility event on top of the PAGE_NAVIGATION event. Availability: Since 1.25.0 |
PUBLIC_DATA_CHANGED | { key1: value1 } | Issued when app data is changed using Wix.Data.Public methods. Note that all registered components will get this event. Availability: Since 1.74.0 |
SCROLL | {"scrollTop": 4, "scrollLeft": 0, "documentHeight": 724, "documentWidth": 1227, "x": 124, "y": 131, "height": 682, "width": 978, "left": 124.5, "bottom": 809, "right": 1102.5, "top": 127} | Issued when scroll happens inside the site. The event data contains multiple details that helps the app determine its behavior considering its position in the site, the browser window dimensions, and the scrolling state: * ScrollTop - site's scroll position on the y axis, * scrollLeft - site's scroll position on the x axis, * documentHeight - site's document height, * documentWidth - site's document width, * x - app offset within the site's page on the x axis, * y - app offset within the site's page on the y axis, * height - app height, * width - app width, * left - app top-left offset from the left, * bottom - app top-left offset from the bottom, * right - app top-left offset from the right, * top - app top-left offset from the top. Availability: Since 1.25.0 |
SETTINGS_UPDATED | Custom json | Issued by the App Settings endpoint when new settings are applied by the user. Availability: Since 1.17.0 |
SITE_METADATA_CHANGED | { title: 'example title', description: 'example description' } | Issued when the page metadata (title, description) changes. Availability: Since 1.75.0 |
SITE_PUBLISHED | {} | Issued when the user publishes the website. Availability: Since 1.13.0 |
SITE_SAVED | {} | Issued when the user saves the website. Availability: Since 1.62.0 |
STATE_CHANGED | {newState: 'state'} | Issued when the website state changed. Read more about the component's state and deep linking here. Availability: Since 1.29.0 |
STYLE_PARAMS_CHANGE | {colors: Object, numbers: Object, booleans: Object, fonts: Object} | Issued when the user changed a color, font, number, or boolean value in your app’s settings panel. Availability: Since 1.22.0 |
THEME_CHANGE | {fonts: Object, siteTextPresets: Object, siteColors: Array (30 colors of palette), style: Object} | Issued when the user changed the site’s color palette. Availability: Since 1.22.0 |
WINDOW_PLACEMENT_CHANGED | "BOTTOM_RIGHT" | Issued when the user changed the position of a fixed-position widget. Availability: Since 1.18.0 |
Retrieves the current Site Member, if one exists.
SDK Version: SDK 1.6.0+
Display: Live Site
Components: Worker
Syntax:
Parameters:
Name | Type | Description |
---|---|---|
callback (required) | Function | Callback function to receive member details |
Value passed to callback:
An object containing the user’s details:
Name | Type | Description |
---|---|---|
name | String | Member's name |
String | Member's email | |
id | String | Member's ID |
owner | Boolean | True if the member is either the site owner or one of the site's contributors |
Retrieves information about the host site.
SDK Version: SDK 1.3.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Worker
Syntax:
Parameters:
Name | Type | Description |
---|---|---|
callback (required) | Function | Callback function to receive the site info |
An object containing the site info:
Name | Type | Description |
---|---|---|
baseUrl | String | Base url of the current site, for example: http://user.wix.com/site-name, http://www.domain.com |
pageTitle | String | The page title that is used for SEO. This title includes both the site and page title (e.g., “My Store - Animal Shirt”). |
pageTitleOnly | String | The name of the page - without the site title (e.g., “Animal Shirt”). |
referrer | String | The referrer header of the HTTP request |
siteDescription | String | The description of the site that is used for SEO |
siteKeywords | String | The keywords which are related to the site and are used for SEO |
siteTitle | String | The title of the site that is used for SEO |
url | String | The URL (taken from the location.href property). The URL includes the internal site state, for example: http://user.wixsite.com/site-name/pageTitle http://www.domain.com/pageTitle. Returns the site URL only when using getSiteInfo in the live site and preview mode. When using it in Editor mode, returns the Editor URL. |
Retrieves all items in the site structure, including:
SDK Version: SDK 1.81.0+
Display: Live Site, Preview
Components: Worker
Syntax:
Note:
Use this method instead of getSitePages, which is now deprecated.
Parameters:
Name | Type | Description |
---|---|---|
callback (required) | Function | Callback function to receive the site structure |
Value passed to callback:
An array of objects, where each object represents an item in the site structure.
Warning:
To use this object later (for example, if you want to navigate to a link on the user’s site), save this object in your database as is – don’t change it in any way.
Each object contains data about the item. The data sent depends on the item – check out our examples below.
Parameters:
Name | Type | Description |
---|---|---|
type | String | Type of link the item represents - for example ‘PageLink’ or ‘AnchorLink’. The data returned depends on the item - for example, an ‘AnchorLink’ object will include the anchorName and anchorDataId properties. Check out our examples below. |
pageId | String | The page ID. Note: If the user added a page anchor to the site’s menu, then this method returns an object for the anchor - so there might be multiple objects with the same page ID. |
title | String | The item title |
hidden | Boolean | Returns true if this page is hidden |
isHomePage | Boolean | Returns true if this page is the site's home page |
url | String | URL of this item |
subPages | Array [objects] | (Page objects only) If the page has subpages, returns an ordered set of subpages. Each subpage object contains more information about the subpage (id, title, hide, isHomePage, url). |
Here’s an example of an array passed to the callback:
Example:
Allows you to check if another one of your apps is installed.
SDK Version: SDK 1.87.0+
Editor Version: New Editor
Display: Preview
Components: Worker
Syntax:
Parameters:
Name | Type | Description |
---|---|---|
appDefinitionId (required) | String | App ID, as specified in the Developers Center |
callback (required) | Function | Callback function that receives a boolean indicating if the app is installed in the site: function(isInstalled) {} |
Example:
Allows you to check if the user added one of your app’s hidden or custom pages (like a thank you or checkout page).
SDK Version: SDK 1.89.0+
Editor Version: New Editor
Display: Live Site, Preview
Components: Worker
Syntax:
Parameters:
Name | Type | Description |
---|---|---|
sectionId (required) | String | ID of the Page component, as specified in the Developers Center |
options | Object | Options for this method |
options.appDefinitionId | String | If the Page component is in a different one of your apps, enter that app’s ID (specified in the Developers Center) |
callback (required) | Function | Callback function that receives a boolean indicating if the Page component is installed in the site: function(isInstalled) {} |
Example:
Allows to remove previously assigned event listeners that were specified using Wix.addEventListener.
SDK Version: SDK 1.25.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Worker
Syntax:
Parameters:
Name | Type | Description |
---|---|---|
eventName (required) | Wix.Events | Unique event identifier |
CallBackOrId (required) | Function | A callback function that was used with addEventListener, or an id returned by addEventListener |
Returns an object containing the user's current policy.
SDK Version: SDK 1.537.0
Display: Live Site
Components: Worker
Important:
Use this method in the live site only. Although it works in the Editor/Preview, it will not return the real policy of the user.
Syntax:
Object Data:
Example:
Returns a String which represents the current device type: Desktop or Mobile.
SDK Version: SDK 1.30.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Worker
Syntax:
Returns a String which represents the app instance ID.
SDK Version: SDK 1.30.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Worker
Syntax:
Returns a String which represents the app IP and port.
SDK Version: SDK 1.30.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Worker
Syntax:
Returns a String which represents the current view mode.
SDK Version: SDK 1.30.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Worker
Syntax:
Navigates to your page component – either to the page component itself or to one of your app’s internal pages.
SDK Version: SDK 1.95.0+
Editor Version: New Editor
Display: Live Site, Preview
Components: Worker
Syntax:
Parameters:
Name | Type | Description |
---|---|---|
options (required) | Object | ID of the page component to navigate to, as well as optional parameters for this method |
options.sectionId (required) | String | ID of the page component, as specified in the Developers Center |
options.appDefinitionId | String | If navigating to a page component in a different app, enter that app’s ID (specified in the Developers Center) |
options.queryParams | Object | Query parameters to add to the page URL when navigating to it, in key value pairs. For example: {param1:value1, param2:value2,...}. These query params are included in the iframe URL (e.g., ?param1=value1¶m2=value2). |
options.state | String | The new app's state to push into the editor history stack |
options.shouldRefreshIframe | Boolean | Indicates if the app iframe should be refreshed when navigating to the page. Default value is true. When queryParams are defined, shouldRefreshIframealways defaults to true. |
options.noTransition | Boolean | Indicates if there should be a transition when navigating to the page. Default value is false. |
onFailure (required) | Function | This will be called if the hosting site does not include the section app, or if the caller's application does not include a section |
Retrieves the user's new policy.
SDK Version: SDK 1.537.0
Display: Live Site
Components: Worker
Important:
Use this method in the live site only. Although it may work in the Editor/Preview, it will not give you real data.
Syntax:
Parameters:
Name | Type | Description |
---|---|---|
callback | function | Callback function to receive the new policy |
Example:
Broadcasts an event to other Site components of a multicomponent app. If the components span multiple pages, they will be notified when they are rendered.
SDK Version: SDK 1.30.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Worker
Syntax:
Parameters:
Name | Type | Description |
---|---|---|
eventName (required)String | The name of the event to publish | |
data (required) | Object | The object to send to subscribers for this event type |
isPersistent (required) | Boolean | Indicates whether this event is persisted for event subscribers who have not yet subscribed |
Subscribes to events from other components of a multicomponent app. If the components span multiple pages, they will be notified once they are rendered. It is also possible to receive all notifications prior to rendering by specifying a flag when subscribing to events. If the flag is set, the component will be notified immediately of any prior events of the type it is registered to receive.
SDK Version: SDK 1.30.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Worker
Syntax:
Parameters:
Name | Type | Description |
---|---|---|
eventName (required) | String | The name of the event to subscribe to |
callBack (required) | Function | Function that will respond to events sent from other components of the broadcasting app. it will be given the event object itself and the source of the event |
receivePastEvents | Boolean | A flag to indicate that all past instances of the registered event should be sent to registered listener. This will happen immediately upon registration |
Unsubscribes from receiving further events. The id from the initial subscribe call is used to unsubscribe from further notifications.
SDK Version: SDK 1.30.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Worker
Syntax:
Parameters:
Name | Type | Description |
---|---|---|
eventName (required) | String | The name of the event to unsubscribe from |
function (required) | Function | The function that will respond to events sent from other extensions of the broadcasting app. it will be given the event object itself and the source of the event |
SDK Version: Deprecated
Note:
Now that this method is deprecated, use the getSiteMap method instead.
Retrieves all pages in this site. A page can be:
Parameters:
Name | Type | Description |
---|---|---|
options | Object | Options for this method |
callback (required) | Function | A callback function to receive the site structure |
Value passed to callback:
An array of objects, where each object represents a page in the site.
The objects are ordered according to the site’s structure shown in the Pages menu of the Wix Editor. If a page has subpages, they are passed as an array of objects nested inside the page object.
Each page/subpage object contains the following properties:
Name | Type | Description |
---|---|---|
id | String | The page/subpage ID. If the user added a page anchor to the site’s menu, then this method returns an object for the anchor - so there might be multiple objects with the same page ID |
title | String | The title of the page/subpage |
hide | Boolean | Returns true if this page/subpage is hidden |
isHomePage | Boolean | Returns true if this page/subpage is the site's home page |
subPages | Array [objects] | (Page objects only) If the page has subPages, returns an ordered set of subpages. Each subpage object contains more information about the subpage (id, title, hide, isHomePage, url). |