Dynamic content creation
Last updated
Last updated
Application Developer notes
Adding dynamic elements to an Aurelia app and the Kendo UI bridge can qualify as one of the requisites for building a large Desktop like GUI or LOB (Line of Business) application. This can either be to migrate an existing application or to create a new one.
Please be aware that "dynamic" should mean the equivalent of adding a DOM node to a HTML page but in this particular case the DOM node consist of Aurelia and Kendo UI Bridge components.
For the following example consider the following use-case. An application has a main menu and a central zone which consists of tabbed panels. When the user selects a menu entry from the menu, a new tab is created and the associated component (as in Aurelia component) is loaded. This would allow for an application both to modularize itself and to load only the needed components. Please find the complete here and some short explanations bellow.
Passing data with a menu entry can be done using something similar to:
The data-id contains the name of the component and the text the title of the tab.
When the menu entry is selected the name and text are retrieved:
To add a new tab, a new DOM node is created using basic js then the CompositionEngine.compose is called provided with a viewModel, the component name, and a slot to attach to, the newly created element.
Please note that the last promise calls the bind and attached method which in turn call the .recreate method on all the Kendo UI Bridge components. This is important.
The magic is derived from the <compose>
Aurelia component. The of this component can be found on github.