[Q] Check which object triggered JS callback

Hi,

I have multiple plots and a data table all based on the same source.

I have the following callback that opens a window only when a single point is selected.

Now I want that the window is only opened when the point is selected in the figure and not when it is selected in the data table.

Is there a way to check which object triggered the callback? Is there a documentation somewhere, where all JS relevant commands are described?

self.sources[i].callback = CustomJS(args=dict(p=p,source=self.sources[i]), code=“”"

var inds = cb_obj.get(‘selected’)[‘1d’].indices;

var d1 = cb_obj.get(‘data’);

var text = ‘’;

var datatext = ‘’;

if (inds.length == 1)

{

datatext = ('Point '+inds[0]);

var data = “

This is ‘myWindow’ for Point “+inds[0]+” : “+d1[‘Col X’][inds[0]]+”

”;

myWindow = window.open(“data:text/html,” + encodeURIComponent(data),

“_blank”, “width=200,height=100”);

myWindow.focus();

}

“”"

)

``

Thanks in advance and keep up the great work,

Tom

I would suggest you’re going to need to not attach the callback to
the source, but instead attach it to a Tap/Select Tool.

Because the cb_obj will always be the source in the case you're

describing.

···

On 10/11/16 2:10 AM, wrote:

[email protected]

Hi,

      I have multiple plots and a data table all based on the

same source.

      I have the following callback that opens a window only when

a single point is selected.

      Now I want that the window is only opened when the point is

selected in the figure and not when it is selected in the data
table.

      Is there a way to check which object triggered the

callback? Is there a documentation somewhere, where all JS
relevant commands are described?

                self.sources[i].callback =

CustomJS(args=dict(p=p,source= self.sources[i]),
code=“”"

                var inds =

cb_obj.get(‘selected’)[‘1d’].indices;

                var d1 =

cb_obj.get(‘data’);

var text = ‘’;

var datatext = ‘’;

if (inds.length == 1)

{

                datatext =

('Point '+inds[0]);

                var data =

This is ‘myWindow’ for Point “+inds[0]+” :
“+d1[‘Col X’][inds[0]]+”

”;

                myWindow =

window.open(“data:text/html,” +
encodeURIComponent(data),

“_blank”, “width=200,height=100”);

myWindow.focus();

}

“”"

)

``

      Thanks in advance and keep up the great work,

Tom

  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/b3fe28ed-8c50-46b7-9ee8-d1b4afcd6b9a%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/b3fe28ed-8c50-46b7-9ee8-d1b4afcd6b9a%40continuum.io?utm_medium=email&utm_source=footer).

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


Sarah Bird
Developer, Bokeh

    [
      ![Continuum Analytics](http://docs.continuum.io/_static/img/ContinuumWordmark.png)
    ](http://continuum.io)

Thank you very much.

Best,

Tom

···

Am Dienstag, 11. Oktober 2016 22:21:20 UTC+2 schrieb Sarah Bird:

I would suggest you're going to need to not attach the callback to

the source, but instead attach it to a Tap/Select Tool.

Because the cb_obj will always be the source in the case you're

describing.

On 10/11/16 2:10 AM, [email protected] > wrote:

Hi,

      I have multiple plots and a data table all based on the

same source.

      I have the following callback that opens a window only when

a single point is selected.

      Now I want that the window is only opened when the point is

selected in the figure and not when it is selected in the data
table.

      Is there a way to check which object triggered the

callback? Is there a documentation somewhere, where all JS
relevant commands are described?

                self.sources[i].callback =

CustomJS(args=dict(p=p,source= self.sources[i]),
code=“”"

                var inds =

cb_obj.get(‘selected’)[‘1d’].indices;

                var d1 =

cb_obj.get(‘data’);

var text = ‘’;

var datatext = ‘’;

if (inds.length == 1)

{

                datatext =

('Point '+inds[0]);

                var data =

This is ‘myWindow’ for Point “+inds[0]+” :
“+d1[‘Col X’][inds[0]]+”

”;

                myWindow =

window.open(“data:text/html,” +
encodeURIComponent(data),

“_blank”, “width=200,height=100”);

myWindow.focus();

}

“”"

)

``

      Thanks in advance and keep up the great work,

Tom

  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/b3fe28ed-8c50-46b7-9ee8-d1b4afcd6b9a%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/b3fe28ed-8c50-46b7-9ee8-d1b4afcd6b9a%40continuum.io?utm_medium=email&utm_source=footer).

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


Sarah Bird
Developer, Bokeh

    [
      <img alt="Continuum Analytics" src="https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000" style="width:150px;min-height:30px" height="30px" width="150px">
    ](http://continuum.io)