System functions

Framework controls have functions that are called by the system at different times. Each system function calls the respective system function of the basic class (TcHmiControl) via the "_super" object and passes a reference to the current control object.

PrevInit function

FrameworkControlJs1.prototype.__previnit = function () {
   /** Handle template elements. Should be done before call to __previnit of super class. */
   this.__elementTemplateRoot = this.getElement().find('.framework-control-js1-template');

   /** Call __previnit of super class. */
   _super.prototype.__previnit.call(this);
};

The PrevInit function is automatically called after the system calls the constructor and before the attribute setters of each attribute are called. Accordingly, the member variables of the attributes have the value "undefined" when the PrevInit function is called. Within the PrevInit function, the references to the HMTL elements are created from the Template.html file.

System functions 1:

This function may only be called by the system and not explicitly by the developer.

Init function

FrameworkControlJs1.prototype.__init = function () {
   _super.prototype.__init.call(this);
};

The Init function is called automatically by the system after the attribute setters of the individual attributes have been called. Accordingly, when the Init function is called, the member variables of the attributes already have the values that were passed to the control or defined internally as default values.

System functions 2:

This function may only be called by the system and not explicitly by the developer.

Attach function

FrameworkControlJs1.prototype.__attach = function () {
   /**
   * Enable everything which was disabled while __detach function was called!
   */
   /**
   * Initialize everything which is only available while the control is part of the active dom.
   */
   /** Call base __attach function */
   _super.prototype.__attach.call(this);
};

The Attach function is automatically called by the system after the current control instance has been added to the DOM of the HTML document. Within the Attach function, all calculations should be performed that are only available while the control instance is in the DOM (e.g. .getBoundingClientRect() of DOM elements or .width() of jQuery elements). The opposite of the Attach function is the Detach function.

System functions 3:

This function may only be called by the system and not explicitly by the developer.

Detach function

FrameworkControlJs1.prototype.__detach = function () {
   /**
   * Disable everything which is not needed while the control is not part of the active dom.
   * No need to listen to events for example!
   */
   /** Call base __detach function */
   _super.prototype.__detach.call(this);
};

The system automatically calls the Detach function after the current control instance has been removed from the DOM of the HTML document. In the Detach function, all functions that are no longer required after the control instance has been removed from the DOM are to be disabled. The opposite of the Detach function is the Attach function.

System functions 4:

This function may only be called by the system and not explicitly by the developer.

Destroy function

FrameworkControlJs1.prototype.destroy = function () {
   /**
   * Free resources
   */
   /** Call base __destroy function */
   _super.prototype.destroy.call(this);
};

The system automatically calls the Destroy function when the control instance is no longer used (after the Detach function). If the control is on an HTML page where "Preload Partial" is enabled, the Destroy function is not called because the page is still saved in the browser cache. Within the Destroy function, the elements that were created during runtime are to be destroyed.

System functions 5:

This function can also be called explicitly (for example when child controls are destroyed).