diff --git a/NEWS.mdtext b/NEWS.mdtext
index 5015f3f..f260965 100644
--- a/NEWS.mdtext
+++ b/NEWS.mdtext
@@ -3,6 +3,7 @@
## Bugfixes
- Compatiblity fixes for PostgreSQL (fixes issue 800)
+- Fix TOC generation in wiki (issue 803)
## Language and Translations
diff --git a/www/media/idf/js/wiki-toc.js b/www/media/idf/js/wiki-toc.js
index 8b59f35..5cea7da 100644
--- a/www/media/idf/js/wiki-toc.js
+++ b/www/media/idf/js/wiki-toc.js
@@ -1,9 +1,12 @@
$(document).ready(function() {
$(":header", "#wiki-content").map(function(index) {
- this.id = "wikititle_" + index;
- $("" + jQuery.fn.text([this]) + "")
- .addClass("wiki-" + this.tagName.toLowerCase())
- .appendTo('#wiki-toc-content');
+ var $header = $(this);
+ var $toc = $('#wiki-toc-content');
+ $header.attr('id', 'wikititle_' + index);
+ $('').attr('href', '#' + $header.attr('id'))
+ .text($header.text())
+ .addClass("wiki-" + $header[0].tagName.toLowerCase())
+ .appendTo($toc);
});
if ($('#wiki-toc-content *').size() < 2)
$('#wiki-toc').hide();