diff options
author | Samy Pesse <samypesse@gmail.com> | 2016-10-04 18:32:31 +0200 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2016-10-04 18:32:31 +0200 |
commit | 16ca48b2c05dad0af4cec600cee69adcafcf255f (patch) | |
tree | 63c1e117c0cf4da989652bd8236375fc9ba3a094 /packages/gitbook-core/src/components/PJAXWrapper.js | |
parent | 87ae2481e4e6f4c6c0756ae379c8c806d95cbb68 (diff) | |
download | gitbook-16ca48b2c05dad0af4cec600cee69adcafcf255f.zip gitbook-16ca48b2c05dad0af4cec600cee69adcafcf255f.tar.gz gitbook-16ca48b2c05dad0af4cec600cee69adcafcf255f.tar.bz2 |
Correctly update page when url changed
Diffstat (limited to 'packages/gitbook-core/src/components/PJAXWrapper.js')
-rw-r--r-- | packages/gitbook-core/src/components/PJAXWrapper.js | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/packages/gitbook-core/src/components/PJAXWrapper.js b/packages/gitbook-core/src/components/PJAXWrapper.js index f35a554..d2eb456 100644 --- a/packages/gitbook-core/src/components/PJAXWrapper.js +++ b/packages/gitbook-core/src/components/PJAXWrapper.js @@ -1,6 +1,6 @@ const React = require('react'); const ReactRedux = require('react-redux'); -const navigation = require('../actions/navigation'); +const Navigation = require('../actions/navigation'); /** * Check if an element is inside a link @@ -61,7 +61,7 @@ function getHrefForEvent(event) { if (link.getAttribute('data-nopjax')) return; - return link.href; + return link.pathname; } /* @@ -83,25 +83,15 @@ const PJAXWrapper = React.createClass({ } event.preventDefault(); - dispatch(navigation.fetchPage(href)); - - }, - - onPopState(event) { - const { dispatch } = this.props; - event.preventDefault(); - - dispatch(navigation.fetchPage(location.href, { replace: true })); + dispatch(Navigation.push(href)); }, componentDidMount() { document.addEventListener('click', this.onClick, false); - window.addEventListener('popstate', this.onPopState, false); }, componentWillUnmount() { document.removeEventListener('click', this.onClick, false); - window.removeEventListener('popstate', this.onPopState, false); }, render() { |