☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Js_on_change for PreText not working in Bokeh Server

Community Supportcustomjs
Saurabh_Lall
Saurabh_Lall

Can anyone please help as to why this code is not working. I am new to bokeh and was trying out the customJS change on Pretext Object.
import pandas as pd
import numpy as np
from bokeh.models import ColumnDataSource, CustomJS, PreText
from bokeh.models.widgets import DataTable, NumberFormatter, TableColumn, Button
from bokeh.io import curdoc
from bokeh.plotting import show
from bokeh.layouts import column

import base64
import io

bt0 = Button(label='Click me')
not_yet_called = True

encodedData = None

data = None
df = None

def prepare_df():
    global not_yet_called
    bool (not_yet_called)
    if not_yet_called:
        not_yet_called = False
        pretext.text="1"
        
    else:
        not_yet_called = True
        pretext.text="2"

pretext=PreText(text='')
print(pretext.text)
pretext.js_on_change('text', CustomJS(code="""alert('Hello')"""))
pretext.text='abcd'
print(pretext.text)

bt0.on_click(prepare_df)
curdoc().add_root(bt0)
⌁   Link to post
Bryan
Bryan

Hi @Saurabh_Lall please edit your post to fix the code formatting so that the code is intelligible (either with the </> icon on the editing toolbar, or triple backtick ``` fences around the code blocks)

Additionally, FYI I have moved the post. It belongs in the Community Support category. The Development category is for topics relating to development of the Bokeh library itself.

⌁   Link to post

End of archived discussion · Replies are disabled