Skip pjax loads if requested path is for different anchor on same page (#444)

This commit is contained in:
Kevin Conaway 2017-10-20 13:03:42 -04:00 committed by Buu Nguyen
parent b7c2155a58
commit c3ad03df18
1 changed files with 5 additions and 1 deletions

View File

@ -65,7 +65,11 @@ class PjaxAdapter extends Adapter {
opts = opts || {}
const $pjaxContainer = opts.$pjaxContainer
if ($pjaxContainer.length) {
// If we're on the same page but just navigating to a different anchor, don't bother fetching the page with pjax
const pathWithoutAnchor = path.replace(/#.*$/, "")
const onSamePage = location.pathname == pathWithoutAnchor
if ($pjaxContainer.length && !onSamePage) {
$.pjax({
// needs full path for pjax to work with Firefox as per cross-domain-content setting
url: location.protocol + '//' + location.host + path,