Accessing button attributes and getting URL from CustomJs code

Hi,
is there any way to access and change button attribute (e.g. name) from CustomJs code? Only solution I’ve found is to send ajax put request. But I need URL for it. In general
window.location.pathname

``

works but I have my widget on Jupyter Notebook and window.location.pathname returns me URL of notebook. So is there any way to get URL of “session” with widget in CustomJs code?
Thanks.

Hi,

Yes. You can pass the button to CustomJS as part it’s args argument and then access it inside the CustomJS javascript code. (more info at the user guide documentation).

As an example of what you are asking for you can see this modified version of the gapminder example .

Cheers

···

On Wed, Oct 21, 2015 at 11:22 AM, Michael Skotnica [email protected] wrote:

Hi,
is there any way to access and change button attribute (e.g. name) from CustomJs code? Only solution I’ve found is to send ajax put request. But I need URL for it. In general
window.location.pathname

``

works but I have my widget on Jupyter Notebook and window.location.pathname returns me URL of notebook. So is there any way to get URL of “session” with widget in CustomJs code?
Thanks.

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/f6184550-589d-400f-ad52-597a25be049e%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Fabio Pliger

Senior Software Engineer, Bokeh

Hi Fabio,
thank you for your help. It works if the button is part of arg. But now I need to handle that change in Python code (button.on_change(…)).
Bokeh.$(‘#button_id’).change();

``

does not work. It works with textinput but not with button. How can I do that?
Thanks

Dne středa 21. října 2015 19:48:02 UTC+2 Fabio Pliger napsal(a):

···

Hi,

Yes. You can pass the button to CustomJS as part it’s args argument and then access it inside the CustomJS javascript code. (more info at the user guide documentation).

As an example of what you are asking for you can see this modified version of the gapminder example .

Cheers

On Wed, Oct 21, 2015 at 11:22 AM, Michael Skotnica [email protected] wrote:

Hi,
is there any way to access and change button attribute (e.g. name) from CustomJs code? Only solution I’ve found is to send ajax put request. But I need URL for it. In general
window.location.pathname

``

works but I have my widget on Jupyter Notebook and window.location.pathname returns me URL of notebook. So is there any way to get URL of “session” with widget in CustomJs code?
Thanks.

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/f6184550-589d-400f-ad52-597a25be049e%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.


Fabio Pliger

Senior Software Engineer, Bokeh

Hi,

Now I’m quite confused about what your use case. Are you using bokeh-server, CustomJS or both? How? Can you provide some more context? Also a code example would help too…

Cheers

Fabio

···

On Thu, Oct 22, 2015 at 10:20 AM, Michael Skotnica [email protected] wrote:

Hi Fabio,
thank you for your help. It works if the button is part of arg. But now I need to handle that change in Python code (button.on_change(…)).
Bokeh.$(‘#button_id’).change();

``

does not work. It works with textinput but not with button. How can I do that?
Thanks

Dne středa 21. října 2015 19:48:02 UTC+2 Fabio Pliger napsal(a):

Hi,

Yes. You can pass the button to CustomJS as part it’s args argument and then access it inside the CustomJS javascript code. (more info at the user guide documentation).

As an example of what you are asking for you can see this modified version of the gapminder example .

Cheers

On Wed, Oct 21, 2015 at 11:22 AM, Michael Skotnica [email protected] wrote:

Hi,
is there any way to access and change button attribute (e.g. name) from CustomJs code? Only solution I’ve found is to send ajax put request. But I need URL for it. In general
window.location.pathname

``

works but I have my widget on Jupyter Notebook and window.location.pathname returns me URL of notebook. So is there any way to get URL of “session” with widget in CustomJs code?
Thanks.

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/f6184550-589d-400f-ad52-597a25be049e%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.


Fabio Pliger

Senior Software Engineer, Bokeh

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/c0ffcc63-a0ed-4f1c-b5f9-42d5fc9e7944%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Fabio Pliger

Senior Software Engineer, Bokeh

Hi,
I’m using Bokeh-server and tap tool. And I need to recognize which coordinates I click on and send that on my Python “app-server” then compute something and send output “back to browser”. So I’m using CustomJs code for tap tool. In JS code I send coordinates through the button attribute “name” (via ajax put request which does not work in Jupyter notebook cause bad URL). In Python code I have button.on_change function which gets coordinates of click. It’s quite weird but I didn’t find another solution.