Hi,
I’ve tried to use the cannonical examples given for the clientside callbacks using a js function.
The code I’m using is exactly the one prescribed:
import dash
from dash.dependencies import ClientsideFunction, Input, Output, State
import dash_core_components as dcc
import dash_html_components as html
app = dash.Dash(__name__)
app.layout = html.Div(children=
[
dcc.Input(id='input', value='hello world'),
html.Div(id='output - clientside'),
html.Div(id='output - serverside')
]
)
@app.callback(
Output('output - serverside', 'children'),
[Input('input', 'value')])
def update_output(value):
return 'Server says “{}”'.format(value)
app.clientside_callback(
output=Output('output - clientside', 'children'),
inputs=[Input('input', 'value')],
clientside_function = ClientsideFunction(
namespace='clientside',
function_name ='display'
)
)
if __name__ == '__main__':
app.run_server(debug=True)
The display.js function sits in the /assets folder and is as foolows:
if(!window.dash_clientside) {window.dash_clientside = {};}
window.dash_clientside.clientside = {
display: function (value) {
return 'Client says "' + value + '"';
}
}
}
Any help would be welcome since I need to accelerate some of my objects’ rendering by sending them to the client side.
Thanks.
1 post - 1 participant