I was managing to do that by using a timeout callback and dummy widgets that I would hide, but there is a better way to do it.
I can just add it in the implementation of a dummy extension of any model.
Here I change the css of and and I add a ‘global’ js function “custom()” that can be called by any JS callback. Similarly I could append new css or js links to the head.
from bokeh.io import curdoc
from bokeh.plotting import figure
from bokeh.models import TextInput, CustomJS
from bokeh.layouts import widgetbox
entry = TextInput(title=‘Test’)
DumClass_code = “”"
import {TextInput,TextInputView} from “models/widgets/text_input”
custom_css = document.createElement(‘style’)
custom_css.id = ‘mystyle’
custom_css.type = ‘text/css’
custom_css.innerHTML = ‘label { color: plum; font-weight:bold } input {width:50px}’
document.body.appendChild custom_css
custom_script = document.createElement(‘script’)
custom_script.id = ‘myscript’
custom_script.type = ‘text/javascript’
custom_script.innerHTML = ‘’’
function custom(){
console.log(‘test’)
}
‘’’
document.body.appendChild custom_script
export class NewTextInputView extends TextInputView
export class NewTextInput extends TextInput
“”"
class DumClass(TextInput):
implementation = DumClass_code
entry.js_on_change(‘value’,CustomJS(code=“custom()”))
curdoc().add_root(widgetbox(entry))
``