Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Update the browser's history on AJAX requests

Roland Geiderc5997e38b0aa
diff --git a/manager/static/js/workout-manager.js b/manager/static/js/workout-manager.js
index e126c964f..14e35b552 100644
--- a/manager/static/js/workout-manager.js
+++ b/manager/static/js/workout-manager.js
@@ -550,13 +550,18 @@ function weight_chart(data)
*/
function load_maincontent()
{
- // TODO: see what can be done about browser history and current URL
$(".load-maincontent").click(function(e) {
e.preventDefault();
var targetUrl = $(this).attr("href");
$.get(targetUrl, function(data) {
+ // Load the data
$('#main-content').html($(data).find('#main-content').html());
+
+ // Update the browser's history
+ current_url = $(data).find("#current-url").html();
+ history.pushState({}, "", current_url);
+
load_maincontent();
});
});