Show views
Stratox.js offers remarkable flexibility. You can use the same component view multiple times in various locations and with varying content.
I will install some pre-made views/components that you are also free to use. Currently, there are only three (ingress, table, and modals), but more will certainly come (read more under Plugins). In the next chapter, I will show you how to build a template view. However, in this chapter, I will focus on how to display views.
Install Startox views/components
How it works
I assume that you have read the installation section and that you have initialized and configured Startox.
1. Import
Let's start with importing a template view/component. I will begin with the easiest one: the ingress component.
2. Set component
Pass the component/view to Stratox; this should be done before the Stratox classes are initialized. Once the component is set, every new Stratox instance will have access to the component.
The setComponent, argument 2 will also take a anonymous function.
3. Initialize instance
Create a class instance and pass a DOM element where you wish to show your template.
4. Add view
Now, add the view to the class instance and pass in the expected content object data to the view.
5. Execute
Execute and display the views/components in the expected DOM element.
5. The HTML
The HTML really just need a starting point but that depends completely on your need, building a app or enhancing a regular page.
6. The result
Combining multiple views
You can combine multiple views, both the same and different, in the same instance. Let's build upon the above example and add the ingress twice, combining them with a new table view:
The result:
Quick create and set component
Can also quick create and set component in one. The setComponent, argument 2 will also take a anonymous function like demonstrated below.
Now let's move on and take a look on how you can build custom templates.
Last updated