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

129
Views
How to re-initiate tailwind's datepicker when added dynamically?

I am using tailwind's datepicker and I add new items by clicking a button:

<html>
   <head>
      <!-- ... -->
      <script src="https://unpkg.com/flowbite@1.5.1/dist/datepicker.js"></script>
   </head>
   <body>
      <!-- ... -->
        <input datepicker type="text" placeholder="Select date">
        <button>Add</button>
      <!-- ... -->
      <script>
        document.querySelector('button').addEventListener('click', function() {
          var input = document.createElement('input');
          input.setAttribute('datepicker', '');
          document.body.appendChild(input);

          document.querySelectorAll('[datepicker]').forEach(function(datepickerEl) {
             new Datepicker(datepickerEl, getDatepickerOptions(datepickerEl));
            // ❌ Unhandled Promise Rejection: ReferenceError: Can't find variable: Datepicker
          });
        });
      </script>
   </body>
</html>

Once a new item has been added, it does not have the datepicker. How can I re-initate the datepicker to all new items?

about 4 years ago · Santiago Trujillo
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!