This is an object that contains data about the environment of the module.

Base #

Each module gets app and context arguments in the init method.

App is the object of the entire application, through which you can access the Kube services and the global methods of the application.

Context is the module's environment object, through which you can access the following module data:

  • DOM element of the module;
  • DOM target element of the module;
  • the module options specified in the data attributes;
  • data-name or ID of the module element.

See an example of how you can access the context in a module.

$K.add('module', 'mymodule', {
    init: function(app, context)
    { = app;

        // context
        this.context = context;
        this.params = context.getParams();
        this.$element = context.getElement();
    myMethod: function()

Context API #


Returns: Dom

Return DOM element of the module, which specified data-kube attribute

this.context = context;
this.$element = context.getElement();


Returns: Dom

Return the DOM element/elements of the module target, if the target is specified in the module settings.

this.context = context;
this.$target = context.getTarget();


Returns: String

Return the data-name attribute of the element or the ID, if data-name was not specified.

this.context = context; = context.getName();


Returns: Object

Return the module option object were specified by the data attributes of the element.

this.context = context;
this.params = context.getParams();

How to extend the module's default settings.

var defaults = {
    message: false

this.context = context;
this.params = context.getParams(defaults);