Use
A code-behind file can be used for JavaScript functionalities that are to apply globally to the entire project. Control events can be registered independently of the HMI side, based on the control ID. Therefore, a code-behind file is particularly suitable for mapping complex functionalities with JavaScript that cannot be performed using the graphical engineering.
Typical applications
- Summary of functionalities: Identical event configurations can be combined in a code-behind file and stored in functions to avoid redundancies (see Action Templates in the Actions and Conditions Editor).
- Global variables: Saving of data used in multiple events to a global variable (see internal symbols in the Configuration window).
- Evaluation of complex objects (e.g. JSON): Processing, validating and evaluating objects.
- Using the framework API: Access to the framework API functions, which cannot be executed via the graphical engineering.
- Dynamic elements: Adding or removing dynamic elements at runtime (e.g. dynamically generate controls at runtime, see ControlFactory).
- Responsive design: Querying the current browser width, switching of grid configurations and loading of different pages depending on the browser width.
- Evaluating URL parameters: Loading different views depending on the browser URL.
- Disabling client interactions: Disabling interactions with other clients via the session ID of the browser.