Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

247
Views
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')
)



about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The solution is simple:

{
setTimeout(window.print, 1000)
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!