# Slider.js\_link

**URL:** <https://discourse.bokeh.org/t/slider-js-link/8419>\
**Category:** Community Support\
**Created:** [September 21, 2021, 1:50am UTC](https://discourse.bokeh.org/t/slider-js-link/8419 "2021-09-21T01:50:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![GabrielaFacio](https://discourse.bokeh.org/user_avatar/discourse.bokeh.org/gabrielafacio/32/3913_2.png) [@GabrielaFacio](https://discourse.bokeh.org/u/GabrielaFacio)\
**Post date:** [September 21, 2021, 1:50am UTC](https://discourse.bokeh.org/t/slider-js-link/8419/1 "2021-09-21T01:50:03Z")

</div>

Hello! I am new at programming and recently I’ve been trying to create an interactive with bokeh. I’ve created the code to display a softmax function. I want to use bokeh to allow the user to change the beta parameter with a slider and see how the plot changes.

I read that a way to connect my code with the slider is with the comand .js\_link . I have the following:

 ![2021-09-20](https://discourse-uploads.bokeh.org/original/2X/9/9d823ded418a7140130b172c1fbb0fbaea9b2187.png)

In line 77 I undestand I have to introduce the beta parameter instead of the ‘line\_width’ but is not possible, I am confused here 😓 😓

---

<div class="post-metadata">

**Author:** ![\_jm](https://discourse.bokeh.org/letter_avatar_proxy/v4/letter/_/ac91a4/32.png) [@\_jm](https://discourse.bokeh.org/u/_jm)\
**Post date:** [September 21, 2021, 1:56pm UTC](https://discourse.bokeh.org/t/slider-js-link/8419/2 "2021-09-21T13:56:19Z")

</div>

Hi @GabrielaFacio

The `js_link` method is a convenience mechanism to bind properties of two bokeh models so that the chosen properties remain synchronized automatically by bokeh without any additional user code.

A slider is a bokeh model; your softmax function is not. And this is the reason why what you are attempting will not work via `js_link`.

You have a few options to easily accomplish your objective. In general it requires writing a callback that is run when the value of the slider changes to update the beta parameter of your softmax function that is plotted.

**OPTION 1:** See the [slider.py](https://docs.bokeh.org/en/latest/docs/gallery/slider.html) example in the bokeh gallery. This example is _conceptually_ very similar to what you have described as your example.

Sliders are used to update parameters of a mathematical function; in that case amplitude, frequency, phase, and offset are controlled by their own dedicated sliders. Here, the callback is written in JavaScript using `js_on_change` methods and `CustomJS` as the JavaScript code that gets invoked when any of the sliders are manipulated.

**NOTE** bokeh uses the prefix js\_ and suffix JS throughout its API as a convention to indicate that things are written in JavaScript.

The benefit of this option is that you can run your function as a standalone application.

**OPTION 2:** Write a python callback and use the on\_change method that invokes it whenever a slider value changes. The implication here is that you need to run your program via the bokeh server, i.e., `bokeh serve ...`, since this is the mechanism to keep the python code and what is running in the browser synchronized.

See the user’s guide for a description of the bokeh server [https://docs.bokeh.org/en/latest/docs/user\_guide/server.html](https://docs.bokeh.org/en/latest/docs/user_guide/server.html).

The user’s guide section on interactions also has more discussion about callbacks, the server, and the on\_change method mentioned above. See [https://docs.bokeh.org/en/latest/docs/user\_guide/interaction/widgets.html](https://docs.bokeh.org/en/latest/docs/user_guide/interaction/widgets.html).

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads.bokeh.org/original/2X/1/14eb24f9e10e4e9b78e3f10f66c04ffa96446e5a.svg) [@system](https://discourse.bokeh.org/u/system)\
**Post date:** [December 20, 2021, 1:56pm UTC](https://discourse.bokeh.org/t/slider-js-link/8419/3 "2021-12-20T13:56:56Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
