JS noob here. I want to load a text file when a TextInput widget value changes, and display it in a Div widget. Below was what I was hoping to do (i.e. my naive use of jQuery load directly on the div object, which doesn’t work). What’s the best way to load a text file and update a Div with the contents, in a callback of a widget?
cb = CustomJS(args=dict(div=div),code="""
div.load( cb_obj.value + ‘/myfile.log’);
“”")
directory.js_on_change(‘value’,cb)
from bokeh.models.widgets import TextInput,Div
from bokeh.models import CustomJS
directory = TextInput(title=“Data directory”,value="~/")
div = Div(width=100)
I could never figure this out. You can access the object js id, to be used in the usual jQuery call: ('#' + div.id).load(cb_obj.value+'/myfile.log'); , but that command does not work either. The previous solutions of putting "var = Bokeh.$" in the JS callback do not work in 0.12.6, since jQuery libraries were removed from BokehJS in 0.12.4 or 5. I had made sure to include the jquery library in my templates/index.html, but still nothing that worked.
I finally just put this in a Python callback to make this work. Seems to serve my purpose.
···
On Wednesday, August 16, 2017 at 5:13:01 PM UTC-4, Michael Churchill wrote:
JS noob here. I want to load a text file when a TextInput widget value changes, and display it in a Div widget. Below was what I was hoping to do (i.e. my naive use of jQuery load directly on the div object, which doesn’t work). What’s the best way to load a text file and update a Div with the contents, in a callback of a widget?
cb = CustomJS(args=dict(div=div),code=“”"
div.load( cb_obj.value + ‘/myfile.log’);
“”")
directory.js_on_change(‘value’,cb)
from bokeh.models.widgets import TextInput,Div
from bokeh.models import CustomJS
directory = TextInput(title=“Data directory”,value=“~/”)
div = Div(width=100)
If you write standalone html files you can edit the html to import jQuery from wherever you like and it will work as you are used to in your js callbacks
On Mon, Aug 21, 2017 at 3:37 PM, Sébastien Roche [email protected] wrote:
If you write standalone html files you can edit the html to import jQuery from wherever you like and it will work as you are used to in your js callbacks
–
You received this message because you are subscribed to a topic in the Google Groups “Bokeh Discussion - Public” group.