2

I am getting error in bokeh button callback: unexpected attribute 'callback' to Button, similar attributes are js_event_callbacks.I copied from working example: is there a way to save bokeh data table content. Code where error ocurrs is presented bellow:

savebutton.callback = CustomJS(
    args=dict(source_data=s1),
    code="""
        var inds = source_data.selected.indices;
        var data = source_data.data;
        var out = "x, y\\n";
        for (i = 0; i < inds.length; i++) {
            out += data['x'][inds[i]] + "," + data['y'][inds[i]] + "\\n";
        }
        var file = new Blob([out], {type: 'text/plain'});
        var elem = window.document.createElement('a');
        elem.href = window.URL.createObjectURL(file);
        elem.download = 'selected-data.txt';
        document.body.appendChild(elem);
        elem.click();
        document.body.removeChild(elem);
        """,
)

I have searched if this error has occured to anybody else, but found nothing yet.

1 Answers1

6

That example was working on Bokeh 1.4.0, and you're probably using Bokeh 2+.

It should work if you replace savebutton.callback = ... with savebutton.js_on_click(...).

Eugene Pakhomov
  • 9,309
  • 3
  • 27
  • 53