Hello Everyone!
I’m using the core component dcc.Clipboard. Clicking the clipboard icon triggers a callback to copy contents from a Dash DataTable to the clipboard and to open an alert that says “Copied!”. This works beautifully on the locally hosted site running through Spyder.
Simplified callback below:
@app.callback(
[Output(component_id=“copy_to_clipboard”, component_property=“content”),
Output(component_id=“alert_Copied”, component_property=“is_open”),],
Input(component_id=“copy_to_clipboard”, component_property=“n_clicks”),
[State(component_id=‘Final_List_datatable’, component_property=“data”),
State(component_id=‘alert_Copied’, component_property=“is_open”),],
prevent_initial_call=True,
)
def CopyFinalTableClipboard(n_clicks, final_table_data, is_open):
if final_table_data is None: # If “Final List” table is blank there will be no update by this callback
return dash.no_update, dash.no_update
finaltableDF = pd.DataFrame(final_table_data)
return clipContent, True
The Issue
When I deployed this version of my app to PythonAnywhere, the dcc.Clipboard no longer seems to be functioning. The Icon (little paper/copy button) is visible, but upon clicking, the callback does not seem to trigger. Nothing is copied to the clipboard and the “Copied” alert does not display.
There is a post on a similar issue: dcc.Clipboard is not working in my company network - #7 by alemedeiros
Unlike these folks, my icon isn’t missing. My site is secure https and my browser hasn’t changed.
I really appreciate any advice that you may have.
If it helps at all, the live site with the malfunction is here: https://www.genetolist.com/
Thanks!