I am using Bokeh to do a dashboard and I would like to create a confirm button when user press on the confirm button, the saveButton will appear. The disabled property of saveButton will change from true to false. I have tried it with the following code and it seems like I have made something wrong. Should I pass the button arguments to Javascript? I am not very familiar with javascript. Thank you for your help
confirmButton = Button(label="Confirm Your Change", button_type="success")
callback = """
if (confirm("Confirm Saving?")) {
saveButton.disabled = false;}
"""
confirmButton.js_on_event(ButtonClick, CustomJS(code=callback))
saveButton = Button(label="Save", button_type="success",disabled=True)
If you want to activate the saveButton by one click (and this stays activated afterwards), simply create the two Buttons, use js_on_click() and pass as an argument the second button. Then you can set the disabled value to false.
confirmButton = Button(label="Confirm Your Change", button_type="success")
saveButton = Button(label="Save", button_type="success",disabled=True)
confirmButton.js_on_click(
CustomJS(
args=dict(saveButton = saveButton),
code="saveButton.disabled = false"
)
)
If you want to toggle the status, use
code="saveButton.disabled = !saveButton.disabled"
inside the CustomJS function.