Returns an instance of a button component that can attach itself to a target and trigger an action on click.

Example

var target = document.getElementById('button-component-target');
var btn = window._elev.buttonComponent(target, {
display_type: 'qmark',
type: 'elevioInline',
actionId: '81565'
});
btn.insert();
// btn._destroy();

Signature

window._elev.buttonComponent(target, options);

target (required)

The DOM node that the button will attach itself to.

options (required)

  • options.type (required)
    One of elevioInline, elevioArticle, elevioModule.
  • options.actionId (required)
    For types elevioInline and elevioArticle it is the ID of the article that should be opened. For type elevioModule it is the ID of the module that should be opened.
  • options.display_type
    One of nothing, underline, throbber, qmark. Defaults to underline.

Instance

A button component instance has the following methods:

insert

Inserts the component into the DOM. If it’s of display_type nothing or underline some CSS classes and a click handler are attached to the target. If display_type is throbber or qmark a new element is inserted to the DOM and attempts to position itself at the top right of the target.

_destroy

Undoes insert logic and destroys component. Instance cannot be used after this is called.

If you use this API or have suggestions for it’s improvement please get in touch about your experience.

See also