diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-04-14 12:32:22 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-04-14 12:32:22 +0200 |
commit | 56e1803b3414be5b27905d6480e127989cb73ead (patch) | |
tree | 85936efa264d44a8008ec14510df96fe32ef2968 /theme/javascript/core/navigation.js | |
parent | c511037f4620275089eb2ca1103522823153764d (diff) | |
download | gitbook-56e1803b3414be5b27905d6480e127989cb73ead.zip gitbook-56e1803b3414be5b27905d6480e127989cb73ead.tar.gz gitbook-56e1803b3414be5b27905d6480e127989cb73ead.tar.bz2 |
Fix title update with pushState navigation
Diffstat (limited to 'theme/javascript/core/navigation.js')
-rwxr-xr-x | theme/javascript/core/navigation.js | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/theme/javascript/core/navigation.js b/theme/javascript/core/navigation.js index c4a7971..853950d 100755 --- a/theme/javascript/core/navigation.js +++ b/theme/javascript/core/navigation.js @@ -28,16 +28,24 @@ define([ function handleNavigation (url, push) { if (typeof history.pushState === "undefined") { - // Refresh the page to the new URL if pushState not supported - location.href = url; + // Refresh the page to the new URL if pushState not supported + location.href = url; + return } - return $.get(url).done(function (data) { - $('.book-body').html($(data).find('.book-body').html()); - $('.book-summary').html($(data).find('.book-summary').html()); + return $.get(url) + .done(function (data) { + var $newPage = $(data); + var title = data.match("<title>(.*?)</title>")[1]; + + $('title').text(title); + $('.book-body').html($newPage.find('.book-body').html()); + $('.book-summary').html($newPage.find('.book-summary').html()); + if (push) updateHistory(url, null); progress.show(); - }).fail(function () { + }) + .fail(function () { location.href = url; }); } |