Dynamic Jet View Creation
You can create apps that allow users build views themselves. New views will behave exactly as ordinary Jet views. They will be navigated to from the URL or with show() and loaded as subviews.
View Locating Logic
You need a way to register newly-created classes so that the app could find them. Create a helper module that will be used to register new views. It will store the hash of view URL segments and the corresponding entities.
Next you need to expand the default view creating logic and redefine the view setting of the JetApp configuration. The app will first look for a view among localViews
. If it does not find anything there, the view will be located as usual, in the views folder.
Now you can use either of the two ways to create views:
a factory function that will return views,
a class that will be the base for all new views.
Jet View Factory
You can define a function that will create new views, e.g.:
Now you can create and register a new view and later navigate to it with view.show() / app.show():
Shared Classes
Define a base class for newly-added views. It must have a constructor and config():
Now you can create and register new views and work with them as with ordinary Jet views stored in files:
Last updated