Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Add a helper function to load the target of a link into the main-content

Roland Geider4944c97c07f5
diff --git a/manager/static/js/workout-manager.js b/manager/static/js/workout-manager.js
index ae985aa57..721e810ef 100644
--- a/manager/static/js/workout-manager.js
+++ b/manager/static/js/workout-manager.js
@@ -478,3 +478,24 @@ function weight_chart(data)
scatterplot_modal_dialog(entry_id);
});
}
+
+
+/*
+ *
+ * Helper function to load the target of a link into the main-content DIV (the
+ * main left colum)
+ *
+ */
+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) {
+ $('#main-content').html($(data).find('#main-content'));
+ load_maincontent();
+ });
+ });
+}
diff --git a/manager/templates/base.html b/manager/templates/base.html
index 10231be75..bb45dec5f 100644
--- a/manager/templates/base.html
+++ b/manager/templates/base.html
@@ -75,6 +75,9 @@
// Init the modal dialog for editing forms
form_modal_dialog();
+
+ // Initialise the hook to reload the main-content
+ load_maincontent();
});
</script>