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

110
Views
Disabling input is delayed

I have an Export button on my page that is creating a PDF (this part is working). During the export process I would like to disable some input or show an overlay to block the user to modify the page. I'm using the code below:

function RenderSelectedChartJsToPDF() {
  // Option 1
  $('.featureInput').attr("disabled", true);
  $("#fileName").attr("disabled", true);
  $("#pdfExport").attr("disabled", true);
  // Option 2
  $("#overlay").show();

  window.jsPDF = window.jspdf.jsPDF;
  const pdf = new jsPDF('portrait', 'mm', 'a4', true);    //portrait or landscape

  var currentTopPosition = topMargin; // Initialisation of the working position.

  RenderPDFHeader(pdf, currentTopPosition);
  RenderPDFGeneralData(pdf, currentTopPosition);
  RenderPDFFooter(pdf, footerHight, 1, pdf.internal.pageCount);

  pdf.save($("#fileName").val() + '.pdf');

  // Re-enable input here
}

The issue is that when I click the export button the PDF will be render and at the end (when the download starts) then the inputs will be disabled. I would like the input to be disabled first then start to build the PDF.

What am I doing wrong?

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

0

As mentioned by @PeterKrebs the issue seems to be the PDF library blocking the browser. I used a setTimeout function to solve my issue as follow:

function RenderSelectedChartJsToPDF() {
  $('.featureInput').attr("disabled", true);
  $("#fileName").attr("disabled", true);
  $("#pdfExport").attr("disabled", true);

  setTimeout(() => { RenderPDF(); }, 1000);    
}

function RenderPDF() {
  window.jsPDF = window.jspdf.jsPDF;
  const pdf = new jsPDF('portrait', 'mm', 'a4', true);    //portrait or landscape

  var currentTopPosition = topMargin; // Initialisation of the working position.
  RenderPDFHeader(pdf, currentTopPosition);
  RenderPDFGeneralData(pdf, currentTopPosition);
  RenderPDFFooter(pdf, footerHight, 1, pdf.internal.pageCount);
  pdf.save($("#fileName").val() + '.pdf');

  // Re-enable input here
}
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!