From 5eec403809726fc2f0e914ef13ad51d15564e9ab Mon Sep 17 00:00:00 2001 From: julian laplace Date: Wed, 26 Oct 2022 17:38:08 +0200 Subject: prev/next working :) --- public/assets/js/vendor/view/router.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'public/assets/js/vendor') diff --git a/public/assets/js/vendor/view/router.js b/public/assets/js/vendor/view/router.js index 0f977e0..3fc3357 100644 --- a/public/assets/js/vendor/view/router.js +++ b/public/assets/js/vendor/view/router.js @@ -1,6 +1,15 @@ var Router = View.extend({ routeByHash: false, + initialize: function () { + window.addEventListener("popstate", this.onpopstate.bind(this)); + }, + + onpopstate: (event) => { + console.log("POP STATE", document.location.pathname); + app.router.parseRoute(document.location.pathname); + }, + go: function (url) { this.parseRoute(url); }, @@ -9,6 +18,7 @@ var Router = View.extend({ if (this.routeByHash) { window.location.hash = url; } else if (window.history) { + console.log(url); window.history.pushState(null, null, url); } }, -- cgit v1.2.3-70-g09d2