I'm making a dropdown which displays a certain plot depending on what is selected.
I've made my dropdown and begun my CustomJS callback function. At the moment, all I want to do is log whatever option is selected in the dropdown, but obviously I cant just console.log(myDropDownMenu.value);
myDropDownMenu = Select(options=['uniform', 'normal', 'lognormal'], value='uniform', title='Distribution')
callback = CustomJS(args=dict(source=source), code=
"""
console.log("What should go in here?");
""")
myDropDownMenu.js_on_change('value', callback)
So if 'uniform' is selected in the dropdown, I expect 'uniform' to show up in my console... Any ideas?
By default the callback object cb_obj
and callback data cb_data
are available in each JS callback. Additionally, when using args
callback attribute you can pass arbitrary number of additional objects as long as they are serializable (like source
in your example). In your case this
is the cb_object
so you can access it's value
property. You may consider using e.g. Google Chrome developers tools (ALT+CMD+I on Mac) to view and inspect those objects in JS console.