Fixed: `this.reload` is now a Function

Closes #65
This commit is contained in:
Maxime Thirouin
2016-03-24 12:38:15 +01:00
parent a5d36d28f8
commit afe0ddb6b9
5 changed files with 15 additions and 4 deletions

View File

@@ -1,3 +1,7 @@
- Fixed: ``currentUrlFullReload`` option now works
- Fixed: ``this.reload`` is now a Function
([#65](https://github.com/MoOx/pjax/issues/65))
# 0.2.2 - 2016-03-12 # 0.2.2 - 2016-03-12
- Fixed: added back standalone version in `./pjax.js` - Fixed: added back standalone version in `./pjax.js`

View File

@@ -19,8 +19,8 @@ document.addEventListener("pjax:success", function() {
document.addEventListener("DOMContentLoaded", function() { document.addEventListener("DOMContentLoaded", function() {
var pjax = new Pjax({ var pjax = new Pjax({
selectors: [".body"] selectors: [".body"],
// currentUrlFullReload: true,
}) })
console.log("Pjax initialized.", pjax) console.log("Pjax initialized.", pjax)
}) })

View File

@@ -9,7 +9,9 @@
<body> <body>
<div class='body'> <div class='body'>
<h1>Index</h1> <h1>Index</h1>
hello. Go to <a href='page2.html'>Page 2</a> and view your console to see Pjax events. Hello.
Go to <a href='page2.html'>Page 2</a> and view your console to see Pjax events.
Clicking on <a href='index.html'>this page</a> will just reload the page entierly.
</div> </div>
</body> </body>
</html> </html>

View File

@@ -51,6 +51,8 @@ Pjax.prototype = {
refresh: require("./lib/proto/refresh.js"), refresh: require("./lib/proto/refresh.js"),
reload: require("./lib/reload.js"),
attachLink: require("./lib/proto/attach-link.js"), attachLink: require("./lib/proto/attach-link.js"),
forEachSelectors: function(cb, context, DOMcontext) { forEachSelectors: function(cb, context, DOMcontext) {

View File

@@ -43,7 +43,10 @@ var linkAction = function(el, event) {
event.preventDefault() event.preventDefault()
// dont do "nothing" if user try to reload the page by clicking the same link twice // dont do "nothing" if user try to reload the page by clicking the same link twice
if (el.href === window.location.href.split("#")[0]) { if (
this.options.currentUrlFullReload &&
el.href === window.location.href.split("#")[0]
) {
el.setAttribute(attrClick, "reload") el.setAttribute(attrClick, "reload")
this.reload() this.reload()
return return