Fix title update with pushState navigation

This commit is contained in:
Samy Pessé
2014-04-14 12:32:22 +02:00
parent c511037f46
commit 56e1803b34
2 changed files with 15 additions and 7 deletions
+14 -6
View File
@@ -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;
});
}