DOMElementHandler interface

The DOMElementHandler interface is used as a base class for DOM handlers in the DOM-side script (typically domSide.js). See DOM calls in the C3 runtime for more information.

Methods

AddDOMElementMessageHandler(handler, func)
Add a message handler to receive messages sent by PostToDOMElement()/PostToDOMElementAsync() in SDKDOMInstanceBase. The handler should match the string the message was posted with. func receives the arguments (elem, e), providing both the associated DOM element and the data argument the message was posted with, if any. When the PostToDOMElementAsync() variant is used, func can be an async method, and it will be awaited and its return value sent back to the runtime to resolve the returned promise.
PostToRuntimeElement(handler, elementId, data)
Post a message to the runtime about this element. For example you could post a "click" message when the element is clicked, in order to trigger On clicked in the runtime. The message is received by AddElementMessageHandler() in SDKDOMPluginBase. handler is a string identifying the message. elementId identifies the element and is used to find the associated runtime instance; pass the element ID provided in CreateElement(). data is an optional extra JSON object to pass along to the message handler.
CreateElement(elementId, e)
Override to create your plugin's DOM element. Note since an element has not been created yet, the runtime identifies it by an assigned elementId, which needs to be passed along to some other calls. The element state is also passed as an argument.
DestroyElement(elem)
Optional override called when the runtime destroys the instance associated with this DOM element. The runtime automatically removes the element from the DOM, but this provides an opportunity for additional cleanup.
UpdateState(elem, e)
Override to update the state of the DOM element according to the element state retrieved from GetElementState() in SDKDOMInstanceBase.
Addon SDK Manual 2019-03-07

On this page