A simple implementation of a SPA with plain JavaScript.
For more info go to: Js: Vanilla script SPA
- place new
.html
toviews/
directory - edit js/app.js file and add new route:
new Route('routeHashTag', 'newView.html', 'about.js', true)
- above will add new route:
localhost/#routeHashTag
with view from fileviews/newView
and loading module 'about.js' on view loading, and this will be default route - some more examples:
new Route('admin', 'admin.html', 'admin.js')
- above will add new route:
localhost/#admin
with view from fileviews/admin.html
and loading module 'admin.js' on view loading, and this will NOT be default route (usual route)
- example module
- modules need to be places to
./modules/
directory
new Module(scriptElement, functionWillBeExecutedAfterViewLoad, functionWillBeExecutedAfterViewDeattach);