-
Notifications
You must be signed in to change notification settings - Fork 0
Router
jsUI comes with a built-in router to allow you to separate your views into javascript files like pages, with one javascript file dictating to the jsUI router where all of this content should go.
import * as jsUI from 'javascript-ui';
import home from './views/home.js';
import page1 from './views/page1.js';
import page2 from './views/page2.js';
jsUI.router([
{url: '/', title: 'Home', name: 'home', view: home},
{url: '/page1', title: 'Page 1', name: 'page1', view: page1},
{url: '/page2', title: 'Page 2', name: 'page2', view: page2}
]);
The url of the page. This should always be prefixed with a forward slash.
The title of the page.
Name of the route you can refer to this later using the routeTo()
or route()
functions.
Takes an array of jsUI elements or single jsUI element.
The Hyperlink()
element has a route()
method that you supply a route name to assign the url of the route with that name.
This function takes the name of a route and returns the url of the route with that name. Returns a '#' if the route does not exist.
This function tells the router to change the current route to the route with that name.