diff options
| author | julian laplace <julescarbon@gmail.com> | 2022-10-26 17:38:08 +0200 |
|---|---|---|
| committer | julian laplace <julescarbon@gmail.com> | 2022-10-26 17:38:08 +0200 |
| commit | 5eec403809726fc2f0e914ef13ad51d15564e9ab (patch) | |
| tree | eb88dd04aeae0eeb418cad48dbf04d1546f7142b /public/assets/js/vendor/view/router.js | |
| parent | 211098a597935494276aa1e43fb92397d549606b (diff) | |
prev/next working :)
Diffstat (limited to 'public/assets/js/vendor/view/router.js')
| -rw-r--r-- | public/assets/js/vendor/view/router.js | 10 |
1 files changed, 10 insertions, 0 deletions
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); } }, |
