Updates to components and elements API
These new and updated functions are now available in the Designer API:
webflow.registerComponent(): You can now create a component without passing a root element (Beta)webflow.getComponent(id): This new function returns a component by its ID (Beta)component.getInstanceCount(): This new function gets the total number of (Beta)instances of a component across an entire site
Also, these functions are updated to accept a tag name such as div, h2, or section instead of only a component or element preset:
element.before(newElement)element.after(newElement)element.prepend(newElement)element.append(newElement)
Beta
These methods are in public beta and may change with future releases.
Creating functions without passing a root element
You can now create a component with the webflow.registerComponent() function without passing a root element.
Instead, you can pass an object with the name for the new component and optionally a group and description, as in this example:
For more information, see Create a component.
Getting components by ID
Previously, to access a component in the Designer API, you had to get a list of components with the webflow.getAllComponents() function and filter by ID.
Now you can use the webflow.getComponent(id) function to get a component by its ID, as in this example:
For more information, see Get component by ID.
Getting the number of instances of a component
You can now get the total number of instances of a component across an entire site with the webflow.getInstanceCount() function:
For more information, see Get component instance count.
Inserting elements by tag name
Previously, when you used one of these functions to insert an element, you had to pass a component object or a preset from the webflow.elementPresets object:
element.before(newElement)element.after(newElement)element.prepend(newElement)element.append(newElement)
Now, you can pass an element to create by the name of the tag, such as div, h2, or section, as in these examples:
For more information, see: