JavaScript newbie question here:
I’d like to allow the user to use a Dropdown widget to load a file. Rather than designing a custom widget, I figured an easy way to do this would be to have a hidden FileInput widget which gets “clicked” via a CustomJS callback when the user clicks the Dropdown widget. I can then use the FileInput widget as normal.
Unfortunately I can’t figure out how to trigger the “click” event on the FileInput widget in the CustomJS callback. Here’s what I tried:
from bokeh.io import curdoc
from bokeh.layouts import column
from bokeh.models import Dropdown, FileInput, CustomJS
# Set up widgets
dropdown = Dropdown(label='File', menu=['Open'])
fileinput = FileInput(visible=False)
# Set up callback for Dropdown widget
dropdown.js_on_click(CustomJS(args=dict(FileInput=fileinput),
code="""
if (this.item == 'Open')
FileInput.click();
"""))
# Set up callback for hidden FileInput widget
def loadfile(attr, old, new):
print(fileinput.filename)
fileinput.on_change('filename', loadfile)
# Set up layouts and add to document
curdoc().add_root(column(dropdown, fileinput))
The FileInput.click() code is not doing anything though…I just get an error in the console that FileInput.click is not a function.
Any tips?

