From be5d58d550c87458a40c28ff6b8c2f78f0946b4e Mon Sep 17 00:00:00 2001 From: Oskar Date: Tue, 19 Dec 2017 13:58:22 +0100 Subject: [PATCH] Asynchronous switch functions (Make sure the DOM is parsed after switching) (#79) * Make sure the DOM is parsed after switching * Fix reload-link in the example --- example/example.js | 3 ++- example/index.html | 2 +- example/page2.html | 2 +- index.js | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/example/example.js b/example/example.js index 9441179..f52f8bf 100644 --- a/example/example.js +++ b/example/example.js @@ -19,7 +19,8 @@ document.addEventListener("pjax:success", function() { document.addEventListener("DOMContentLoaded", function() { var pjax = new Pjax({ - selectors: [".body"], + elements: [".js-Pjax"], + selectors: [".body"] // currentUrlFullReload: true, }) console.log("Pjax initialized.", pjax) diff --git a/example/index.html b/example/index.html index 8e259b9..cc95a19 100644 --- a/example/index.html +++ b/example/index.html @@ -10,7 +10,7 @@

Index

Hello. - Go to Page 2 and view your console to see Pjax events. + Go to Page 2 and view your console to see Pjax events. Clicking on this page will just reload the page entierly.
diff --git a/example/page2.html b/example/page2.html index b997abb..36d2e33 100644 --- a/example/page2.html +++ b/example/page2.html @@ -9,7 +9,7 @@

Page 2

- Hello. Go to Index. + Hello. Go to Index.
diff --git a/index.js b/index.js index b7f7b3b..bd7bc56 100644 --- a/index.js +++ b/index.js @@ -83,6 +83,7 @@ Pjax.prototype = { }, onSwitch: function() { + this.parseDOM(document) trigger(window, "resize scroll") },