ReactiveHTML: trigger python callback in the _scripts object

Hi,

I am wondering if it’s possible to trigger a python callback in the _scripts object in a ReactivHTML component.

For example, if we take the example given on the documentation site and modify slightly the example as follow this work:

import param
from panel.reactive import ReactiveHTML
import panel as pn
pn.extension() # for notebook

class Slideshow(ReactiveHTML):

    index = param.Integer(default=0)
    trigger = param.Integer(default=0)

    _template = '<img id="slideshow" src="https://picsum.photos/800/300?image=${index}" onclick="${script('click')}"></img>'

    _scripts = {
        'click': """
            data.trigger = data.trigger + 1
         """
   }

    @param.depends("trigger", watch=True)
    def _img_click(self):
        self.index += 1

Slideshow(width=800, height=300)

However, without using the depends decorator and the trick of incrementing the trigger param, how can one call the _img_click callback in the scripts object directly?

This example above is a bit silly and I know that one can call the _img_click callback directly on the image tag itself, but this is more like a general question to see if it’s possible to call directly a python callback in _scripts in the situation where a python callback cannot be directly attached/triggered to a dom element.