The following methods are optional for you to implement per behavior.
Behaviors are extensions of modules with very similar interfaces.
They add common functionality and event handling to modules but do not actually interact with the original module.
For example, two modules can use an “item” behavior to handle complex click actions but the behavior itself
does not care which module is using it. It does it’s own thing and that is it.
Initializes the behavior. This method is fired automatically when Box.Application.start is called on the related module.
Destroys the behavior. This method is fired automatically when Box.Application.stop is called on the related module.
Message handlers for behaviors are the same as Module.messages. Each one is handled separately and both can execute off the
List of messages that this behavior will listen for. This is used by Box.Application to fire onmessage handlers.
You should place this at the top of the behavior API so it is easy to find.
Handles application messages.
This message handler function should be placed above event handlers.
The message name.
Related data for the message.
Handles specific DOM events that are fired within the module behavior. These handlers follow the on convention.
For example, 'onclick' handles click events and 'oncontextmenu' handles right click.
List of handled events:
Note: blur/focus events are very flaky and are not supported by Box.Application. For special events, you should define
The handler function should delegate complex logic to other functions. As a rule of thumb, try NOT to pass
the event object around.
Note: Behavior event handlers are processed after the module event handler. Handlers should not overlap so be careful
of default case handling.
A DOM-normalized event object.
The nearest HTML element with a data-type attribute specified or null if there is none.
The value of data-type for the nearest element with that attribute specified or null if there is none.