Loading text file within CustomJS

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

Thanks. Unfortunately, I am using bokeh server.

···

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.

To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/bokeh/TLLg-8TrqIs/unsubscribe.

To unsubscribe from this group and all its topics, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/7269f38b-649e-4c30-95d9-8c7a06b96f04%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

R. Michael Churchill