UIJS is a simple and lightweight solution for routing pages in single page
applications.
It integrates with jQuery and makes page transitions a breeze. It depends on hashes instead of real paths thus we can easily isolate the client and server.
This is a lazy approach. I made it because I didn't felt like
using Vue or Angular for a simple app.
The 6 step implementation
- Link ui.js file to page
- Initialize or fetch an object 'Path' which consists of route & div id in pairs (to bind a div to a route)
- Add 'ui' class to all divs representing a page
- Add 'display: none' property to ui class in css
- Use 'uNav(route)' function to switch pages with user events
- Create a div with id 'e' for 404s
Now go ahead ... test / play / integrate
PS. You need to have jQuery linked
This is a sample page which has no purpose!
Note this page loads by default with the url
Click Me
That's what this is all about!
Also try adding a random string after #