new InstanceManager(params)
Creates an instance of the InstanceManager.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object | The parameters for the InstanceManager. Properties
|
Methods
-
(instanceView, instanceModel, beforeElement)
-
Syncs Instance View HTML with Instance Model
Parameters:
Name Type Description instanceView
instanceModel
beforeElement
Returns:
addedHtmlElement, if HTML is added, otherwise null
-
updateCloneIds(html, oldId, newModel)
-
Updates clone IDs in the HTML based on the old ID and new model
Parameters:
Name Type Description html
HTMLElement The HTML element to update
oldId
string The old ID to replace
newModel
object The new model associated with the HTML element
-
updateTemplate(childView)
-
Updates the template with the given child view
Parameters:
Name Type Description childView
object The child view to update the template with
-
addInstance(event, payload)
-
Adds an instance based on the event and payload
Parameters:
Name Type Description event
object The event object
payload
object The payload associated with the event
-
removeInstance(event, payload)
-
Removes an instance based on the event and payload
Parameters:
Name Type Description event
object The event object
payload
object The payload associated with the event
-
handleAddition(addedInstanceJson, beforeElement)
-
Inserts HTML for the added instance
Parameters:
Name Type Description addedInstanceJson
object The JSON representation of the added instance
beforeElement
HTMLElement The element before which the instance should be added
Returns:
The added HTML element
- Type
- HTMLElement
-
getElementAt(index)
-
Gets the HTML element at the given index
Parameters:
Name Type Description index
number The index of the element
Returns:
- Type
- Element
-
handleRemoval(removedInstanceView)
-
Removes HTML for the removed instance
Parameters:
Name Type Description removedInstanceView
object The view of the removed instance
-
addChild(childView)
-
Adds a repeatable instance view
Parameters:
Name Type Description childView
object The child view to add
Fires:
-
updateItems(prevValue, currentValue, state)
-
Adds or removes repeatable children
Parameters:
Name Type Description prevValue
object The previous value (removed instance) or null
currentValue
object The current value (added instance) or null
state
object The state object
-
subscribe()
-
Subscribes model for change handler
-
getId()
-
Gets the ID of the instance manager
Returns:
The ID
- Type
- string
-
getModel()
-
Gets the model associated with the instance manager
Returns:
The model
- Type
- object
-
setRepeatableParentView(parentView)
-
Sets the repeatable parent view
Parameters:
Name Type Description parentView
object The repeatable parent view
-
getRepeatableParentView()
-
Gets the repeatable parent view
Returns:
The repeatable parent view
- Type
- object