• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

186
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')
)



almost 3 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The solution is simple:

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

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda