Hi,
Is it possible to have a widget callback function call a sub-function?
I have a number of callback functions that share some common code and I’d like to move that common code into a function to avoid code duplication.
I see the color_sliders example: color_sliders.py — Bokeh 2.4.2 Documentation
defines sub-functions within the definition of the callback but this doesn’t help my situation.
Here is a contrived example of what I’m trying to accomplish:
sub_function = CustomJS( args=dict(source=source), code = “”"
source.trigger(‘change’);
“”")
callback_select = CustomJS( args=dict(source=source), code="""
var data = source.data;
var v = cb_obj.value;
data[‘y’] = data[v];
sub_function( source )
“”")
When callback_select is run, I get the error “sub_function is not defined”.
thanks
albert.