Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Comercial
    • Calculadora

0

109
Vistas
DASH Javascript client-side call back precedes Python triggered call_back

I have a dash app, where a Print button executes a window print in Javascript using a client-side callback. I would like the Print button to trigger a python call-back BEFORE it triggers the Javascipt window-print so that I can hide a layout feature and prevent it from being displayed. No matter what I try, the javascript print window opens first and only on closing that window does the other python call-back get triggered. Is there a work around? Thx

dbc.Button('Print Record', id='printing', outline=True, className="d-print-none",
                                   n_clicks=0,)

@app.callback(
    [,
        Output("printing", "n_clicks"),
    ],

    [Input("printing", "n_clicks")],
)
def toggle_sidebarnclick(n):
    "code toggles a layout feature so it doesn't appear on the screen"

    return n

app.clientside_callback(
    """
    function(clicks) {
        if (clicks > 0) {
          try {
  document.execCommand('print', false, null);
}
catch(e) {
  window.print();
}
        }
        return 
    }
    """,
    Output('hidden-content', 'children'),
    Input('printing', 'n_clicks')
)



7 months ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The solution is simple:

{
setTimeout(window.print, 1000)
}
7 months ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos