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

328
Views
How to reload a JavaScript of a page without reloading the page (Vanilla JS)

I have nested fields that are being appended to the DOM when a user wants to add more fields. this is being done by a nested_fields.js file.

The issue is one of the fields being appended is a calender field that is being handled by another JS file called calender_manager.js

calender_manager.js is using the Flatpickr module and it looks for input tags with the .flatpickr class in the HTML file of the page. This happens when the page is loaded so the fields appended to the DOM by nested_fields.js with the .flatpickr class don't get picked up by calender_manager.js.

So far my solution is to make one custom JS file for the nested calendar fields that handles appending the nested fields and adding flatpickr. I was wondering if there is a better way.

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

0

I've never heard of flatpickr but I just looked into it, maybe I don't know what you are asking, but are you trying to get it to enable after the page loads? If so calling flatpickr(".my_input"); again works.

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>

<input type="text" class="my_input" /><br />
<input type="button" id="enable" value="Click to enable flatpickr" />
<input type="button" id="disable" value="Click to disable flatpickr" />

<script>
var f;
document.querySelector("#enable").onclick = function () {
    f = flatpickr(".my_input");
}
document.querySelector("#disable").onclick = function () {
    f.destroy();
}
</script>
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!