Triggering a python callback function from a clicked html link in a html panel

I create html content programmatically and display it in a html panel.
I need some way of triggering a python callback function in my app when links are clicked. How do I do this in panel?

Likely ReactiveHTML

https://panel.holoviz.org/explanation/components/reactive_html_components.html

Thank you for your response, much appreciated!

However, I seem to have a very poor understanding of ReactiveHTML:
Below is my smallest code snippet to demoinstrate my problem - I want Document 1, when clicked, print “doc 1”, anbd Document 2 when clicked “doc 2” as per the id
But whether I click Document 1 or 2, it will always print “doc 1”. Why? How can I make it behave as I want it to?

from panel.reactive import ReactiveHTML
pn.extension()

class FuncTest(ReactiveHTML):

    _template = """<span id="doc 1" onclick="${linkClicked}"> [Document 1] </span>  
                   <span id="doc 2" onclick="${linkClicked}"> [Document 2] </span>"""
   
    def linkClicked(self, event):
        print(event.node)

FuncTest().servable()

Few thoughts:

  1. I think because they both reference the same linkClicked, it links to doc 1.
  2. Might be a bug? Not entirely sure but feel free to file an issue on Panel GitHub!
import panel as pn
from panel.reactive import ReactiveHTML

pn.extension()

class FuncTest(ReactiveHTML):

    _template = """<span id="doc1" onclick="${linkClicked}"> [Document 1] </span>  
                   <span id="doc2" onclick="${linkClicked2}"> [Document 2] </span>"""
   
    def linkClicked(self, event):
        print(event.node)

    def linkClicked2(self, event):
        print(event.node)

FuncTest().servable()