foundation-layout.foundationlayout.registeritem
Home > @genesislcap/foundation-layout > FoundationLayout > registerItem
FoundationLayout.registerItem() method
Register a collection of Element
and associate them with an ID
with the layout system for later use.
Signature:
registerItem(registration: string, elements: Element[]): string;
Parameters
Parameter | Type | Description |
---|---|---|
registration | string | string of the registration ID |
elements | Element[] | Elements[] containing the reference to the elements to register for later usage |
Returns:
string
- string defining the name of the registered item with the layout system (config.id if set).
Exceptions
LayoutUsageError if you attempt to add an item before the layout has been initialised.
LayoutRegistrationError if you attempt to use a registration
name which is already in use (declarative html API and JavaScript API registrations use the same "pool" of registration names).
Remarks
You would use this to register elements that you later want to load when using FoundationLayout.loadLayout(). Use FoundationLayout.layoutRequiredRegistrations() to see what components need to be registered for a certain config and then register them using this function before calling FoundationLayout.loadLayout().
When registering an element it is moved by reference into the internals of the layout, so if you pass elements already in the DOM then they will disappear. If you want to avoid this you can pass copies using element.cloneNode(true)
.