summaryrefslogtreecommitdiff
path: root/public/assets/js/vendor/view/router.js
diff options
context:
space:
mode:
authorjulian laplace <julescarbon@gmail.com>2022-10-26 17:38:08 +0200
committerjulian laplace <julescarbon@gmail.com>2022-10-26 17:38:08 +0200
commit5eec403809726fc2f0e914ef13ad51d15564e9ab (patch)
treeeb88dd04aeae0eeb418cad48dbf04d1546f7142b /public/assets/js/vendor/view/router.js
parent211098a597935494276aa1e43fb92397d549606b (diff)
prev/next working :)
Diffstat (limited to 'public/assets/js/vendor/view/router.js')
-rw-r--r--public/assets/js/vendor/view/router.js10
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);
}
},