TextInput Callback not working

TextInput Value is not being fetched by javascript call back the TextAreaInput is working fine and it is displaying the entered value in console on Tab click.
But i need the to fetch the TextInput Value also. Please help!

from bokeh.layouts import layout, column
from bokeh.models.widgets import Div
from bokeh.io import show
from bokeh.models import TextInput, CustomJS, TextAreaInput
from bokeh.io import output_file

ti = TextInput(title="ti")
callback = CustomJS(code="""
var f=cb_obj.value;
console.log("hello ti");
console.log(f);""")
ti.js_on_change("value", callback)

tia = TextAreaInput(title="tia")
callback = CustomJS(code="""
var f=cb_obj.value;
console.log("hello tia");
console.log(f);""")
tia.js_on_change("value", callback)

doc_layout = layout()
doc_layout.children.append(column(Div(text="""<h1>Hello World!</h1>""")))
doc_layout.children.append(ti)
doc_layout.children.append(tia)
output_file('TestInput.html', mode='inline')

show(doc_layout)

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

@Bryan done code formatting.Thank You . Looking forward for help .

Works just fine for me with Bokeh 2.0.2.
Note that js_on_change is triggered only when you hit Enter or when the input field loses focus. If you want to see updates for every key press then you should monitor the value_input attribute instead of value.

1 Like

For text area i am getting the callback print contents as configured on console .
But for text input it is blank and printing nothing on console .

What is your Bokeh version?

Bokeh 2.0.0

I should’ve asked earlier - what browser do you use?
If it’s Edge, then there’s this issue: [BUG] TextInput.on_change() doesn’t work on Microsoft Edge · Issue #9985 · bokeh/bokeh · GitHub

1 Like

Yes i am using Edge . Oh i see. What others widget on_change action wont work in edge?

What is the solution for this ?

Alas, I don’t know anything beyond of what’s mentioned in the issue.

Thank You so much . I think edge is the issue it works on other browsers.

Do value_input works with text area ?