getNestedWidget( )


Gets the wix-widget module scoped to an inner (nested) widget.

The getNestedWidget() function lets you use wix-widget functions on inner (nested) widgets. It receives a selector of an inner widget and returns a promise that resolves with an object representing the scope of the inner widget.

Note: The getNestedWidget() function doesn't work in preview mode.

Method Declaration
Copy
function getNestedWidget(Selector: string): Promise<object>;
Method Parameters
SelectorstringRequired

A string of one or more nested widget selectors, which can include a few levels of nesting from outer to inner, separated by spaces. For example: ("#nestedWidget1"), or ("#nestedWidget1 #nestedWidget2").

Returns
Return Type:Promise<object>
Get a nested widget's preset
JavaScript
import wixWidget from "wix-widget"; //... wixWidget .getNestedWidget("#nestedWidget1 #nestedWidget2") //nestedWidget2 is inside nestedWidget1 .then((nestedWixWidget) => nestedWixWidget.getDesignPreset()) .then((nestedWidgetPreset) => { // do something with the design preset of nestedWidget2 });
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?