I’m trying to embed a javascript genome browser (https://jbrowse.org/docs/embedding.html#embedding-in-a-div-with-dynamic-configs) within a tab.
I’ve read the section on running local js in https://dash.plot.ly/external-resources. As best I can tell, that executes a piece of javascript when you first enter the app.
If I have the following app layout:
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div(children=[
html.Tr([
html.Td(children=[ generateColumns(tier0df)]),
html.Td([
dcc.Tabs(id="tabs", value='tab-1', children=[
dcc.Tab(label='Tier 1', value="tab-1"),
dcc.Tab(label='Tier 2', value='tab-2'),
dcc.Tab(label='Genome Browser', value='tab-3')
],style=tabs_styles),
html.Div(id='tabs-content'),
], style={"width":80}),
])
], className='row' )
app.css.append_css({
'external_url': 'https://codepen.io/chriddyp/pen/bWLwgP.css'
})
This executes the js file found in assets directory, as the external resources pages suggests it should - but only when the the app is first entered. I’ve got the following callback,
def render_content(tab, selectedColumns):
if tab == 'tab-1':
return html.Div([
generate_table(tier0df, selectedColumns)
])
elif tab == 'tab-2':
return html.Div([
generate_table(tier1df,selectedColumns)
])
elif tab == 'tab-3':
return html.Div([
*<something something something call js here>*
])
How does one call the relevant piece of javascript code only when the 3rd tab is selected and embed the results in that tab?
Thanks
Ben.