diff --git a/src/moin/converters/html_out.py b/src/moin/converters/html_out.py
index 29568ae42..296fae583 100644
--- a/src/moin/converters/html_out.py
+++ b/src/moin/converters/html_out.py
@@ -751,14 +751,7 @@ def __call__(self, element):
headings_list = [h[1] for h in headings]
if headings_list:
maxlevel = max(headings_list)
- headtogglelink = html.a(
- attrib={
- html.class_: "moin-showhide",
- html.href_: "#",
- html.onclick_: "$('.moin-table-of-contents ol').toggle();return false;",
- },
- children=["[+]"],
- )
+ headtogglelink = html.a(attrib={html.class_: "moin-showhide", html.href_: "#"}, children=["[+]"])
elem_h = html.div(
attrib={html.class_: "moin-table-of-contents-heading"}, children=[_("Contents"), headtogglelink]
)
@@ -790,14 +783,7 @@ def stack_top_append(elem):
if need_item:
stack.pop()
stack_push(html.li({html.id_: f"li{id}"}))
- togglelink = html.a(
- attrib={
- html.href_: "#",
- html.onclick_: f"$('#li{id} ol').toggle();return false;",
- html.class_: "moin-showhide",
- },
- children=["[+]"],
- )
+ togglelink = html.a(attrib={html.href_: "#", html.class_: "moin-showhide"}, children=["[+]"])
elem_a = html.a(attrib={html.href: "#" + id}, children=[text])
stack_top_append(elem_a)
old_toggle = togglelink
diff --git a/src/moin/static/js/common.js b/src/moin/static/js/common.js
index 5176bdf3b..ea77bbf95 100644
--- a/src/moin/static/js/common.js
+++ b/src/moin/static/js/common.js
@@ -919,6 +919,14 @@ $(document).ready(function () {
// placing initToggleComments after enhanceEdit prevents odd autoscroll issue when editing hidden comments
moin.initToggleComments();
+ $('.moin-table-of-contents .moin-showhide').on('click', function (event) {
+ event.preventDefault();
+ var parent = $(this).parent();
+ if ($(parent).is('.moin-table-of-contents-heading')) {
+ parent = $(parent).parent();
+ }
+ $(parent).find('ol:first-of-type').toggle();
+ });
moin.restoreFlashMessages();
});