Hello everyone,
I’ve been trying for a while to add an onclick event to a bokeh Div widget in order to raise a callback. However, it’s not possible to do it since it’s not natively defined.
I also tried to create a “Custom” class from Div to add the on-click event but I didn’t succeed either.
If you have any suggestions, I’m interested…
Thank you in advance.
Are you 100% sure that having a clickable div is a good idea in your case? Is there really a good reason to not just use a Button
?
For reference, this question has been asked many times before. Just the first 3 from Discourse that I found:
The answer is the same every time - either use a Button
or create a custom model that doesn’t require Bokeh events to know that a user has clicked on it. For an example, take a look at how AbstractButtonView.render
is implemented - it uses a regular JS event to know when the button is clicked.
Thank you for you answer and the references !