Fix issue #14 (click reload).
This commit is contained in:
12
src/pjax.js
12
src/pjax.js
@@ -27,6 +27,7 @@
|
|||||||
this.options.switches = this.options.switches || {}
|
this.options.switches = this.options.switches || {}
|
||||||
this.options.switchesOptions = this.options.switchesOptions || {}
|
this.options.switchesOptions = this.options.switchesOptions || {}
|
||||||
this.options.history = this.options.history || true
|
this.options.history = this.options.history || true
|
||||||
|
this.options.clickReload = this.options.clickReload || false
|
||||||
this.options.analytics = this.options.analytics || function(options) {
|
this.options.analytics = this.options.analytics || function(options) {
|
||||||
// options.backward or options.foward can be true or undefined
|
// options.backward or options.foward can be true or undefined
|
||||||
// by default, we do track back/foward hit
|
// by default, we do track back/foward hit
|
||||||
@@ -271,10 +272,13 @@
|
|||||||
|
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|
||||||
// don’t do "nothing" if user try to reload the page
|
// If options.clickReload is true, when a user click twice on a link,
|
||||||
if (el.href === window.location.href) {
|
// try to reload the page. Otherwise, do nothing.
|
||||||
window.location.reload()
|
if (this.options.clickReload) {
|
||||||
return -6
|
if (el.href === window.location.href) {
|
||||||
|
window.location.reload()
|
||||||
|
return -6
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loadUrl(el.href, Pjax.clone(this.options))
|
this.loadUrl(el.href, Pjax.clone(this.options))
|
||||||
|
|||||||
Reference in New Issue
Block a user