platform: OSX 10.11.6
Browser: Chrome 52.0.2743.116
Bokeh: 0.12.1
Django: 1.9.8
Python: 3.5.2
as an example we can use this, which has the same problem as mine.
#onChangeExample.py
from __future__ import print_function
from bokeh.models import MultiSelect, Select, CustomJS, VBox
from bokeh.io import curdoc
from bokeh.client import push_session
def update(attrname, old, new):
print("""MultiSelect\nOptions: %s\nSelected:%s\n\n
Select\nOptions:%s\nSelected: %s"""
% (mscolors.options, mscolors.value, colors.options, colors.value))
# set up select widget
def main():
colors = Select(title="colors", options=["Red", "Green", "Blue"])
colors.on_change('value', update)
colors.callback = CustomJS(code="console.log('Select: ' + cb_obj.get('value'))")
# set up multiselect widget
mscolors = MultiSelect(title="Colors", options=["Red", "Green", "Blue"])
mscolors.on_change('value', update)
mscolors.callback = CustomJS(code="console.log('MultiSelect: ' + cb_obj.get('value'))")
curdoc().add_root(VBox(colors, mscolors))
session = push_session(curdoc())
return session
``
then in my views.py in Django
import …/pathto/…/onChangeExample as onChange
the_script = autoload_server(model=None, session_id=onChange.main().id)
return render(request, "simple_chart.html", {'the_script': the_script })
``
then in my simple_chart.html
Experiment with Bokeh
{{ the_script| safe }}
``
IN TWO TERMINAL WINDOWS
running(bokeh): bokeh serve --allow-websocket-origin=127.0.0.1:8000
running(python): python3 manage.py run server
WHAT HAPPENED
The graph shows. The customJS callback is working and I am getting prints in my js inspector. Yet I am getting no prints on the shell of my bokeh server
WHAT I EXPECT TO HAPPEN
When I run the graph using
bokeh serve --show onChangeExample.py --allow-websocket-origin=127.0.0.1:8000
``
the graph shows. I get prints in the js inspector, and i get prints on the shell of my bokeh server