Cds js on change callback not firing (on bokeh server, but python callback does fire)

Hi, I’m trying to fire a js callback from a change in the From my understanding you need to replace it entirely for it to work, which I thought I’m doing, but it doesn’t appear to work for me. A python callback off the same cds is working however. This is running on a bokeh server, and with bokeh 2.3.0

I just replied to an older thread about it (apologies), which was similar but not quite the same where the changes were in-place (CDS.js_on_change not called, but CDS.on_change is - #4 by Bryan).

Any help on what I’m doing wrong gratefully received. Thanks.

from bokeh.models import ColumnDataSource
from import curdoc
from bokeh.layouts import layout
from bokeh.models import Button
from bokeh import events
from bokeh.models.callbacks import CustomJS

def bkapp(doc):
    ### set up dummy cds and a button
    button_dummy=Button(label="Test Button_dummy", button_type="success", width=60)

    ### callback for the button, to update the cds
    global dummy_int
    def button_callback(event):
        print("button has been pressed")
        global dummy_int
        dummy_int +=1
        temp=dummy_int{"counter": [temp]}

    ### callbacks I'd like to trigger after pressing the button, via the cds change
    js_counter_callback = CustomJS(args=dict(cds_counter=cds_counter), code="""
                console.log("test test test is not running")
    def py_counter_callback(attr, old, new):
        print("should run when counter in cds changes??")
    cds_counter.on_change("data", py_counter_callback)
    cds_counter.js_on_change("data", js_counter_callback)

global doc
doc = curdoc()

@sirspoon To be honest this just seems like it might be a bug specific to CustomJS callbacks and Unlike almost all other properties, CDS .data has some special-case codepaths, and perhaps they are interfering with triggering JS callbacks. would suggest filing a GitHub Issue with this test case.

1 Like

thanks very much… willdo :+1:

1 Like