Js_on_event on Div widget

Is it possible to use js_on_event for Div widgets? I would ultimately like to trigger a callback in python whenever an event is triggered on a Div widget (tap, press, mouse enter, mouse leave, etc), and I suppose going through js_on_event is the way to do that(?). Anyways, I have tried the following:

from bokeh import events
from bokeh.layouts import layout
from bokeh.models import CustomJS, Div

from lib.bokeh.util.bokeh_util import display

div = Div(style={'background': 'gray', 'min-width': '500px', 'min-height': '500px'})

div.js_on_event(events.Tap, CustomJS(code="""
    console.log("Does this work?")
    """))

display(layout(div, sizing_mode='stretch_both'))

But this does not seem to have any effect.

display is a convenience function that fires up a bokeh Server.

@p-himik already answered this quesion on Stack overflow:

Please, if you are going to x-post questions in multiple places, state that you are doing that, and leave links.

1 Like