From f9c5929e2d4ed6b2b0db49090377c0071f165048 Mon Sep 17 00:00:00 2001 From: Gilles Fabio Date: Mon, 1 Sep 2014 09:47:28 +0200 Subject: [PATCH] Fix issue #14 (click reload). --- src/pjax.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/pjax.js b/src/pjax.js index 8bc95f2..b9e818c 100644 --- a/src/pjax.js +++ b/src/pjax.js @@ -27,6 +27,7 @@ this.options.switches = this.options.switches || {} this.options.switchesOptions = this.options.switchesOptions || {} this.options.history = this.options.history || true + this.options.clickReload = this.options.clickReload || false this.options.analytics = this.options.analytics || function(options) { // options.backward or options.foward can be true or undefined // by default, we do track back/foward hit @@ -271,10 +272,13 @@ event.preventDefault() - // don’t do "nothing" if user try to reload the page - if (el.href === window.location.href) { - window.location.reload() - return -6 + // If options.clickReload is true, when a user click twice on a link, + // try to reload the page. Otherwise, do nothing. + if (this.options.clickReload) { + if (el.href === window.location.href) { + window.location.reload() + return -6 + } } this.loadUrl(el.href, Pjax.clone(this.options))