jQuery UI datepicker and Dynamic Forms

When implementing jQuery UI’s datepicker in a dynamic form, you may notice that it will break as you bind it to new elements. The datepicker method adds a “hasDatepicker” class which must be removed first.

This example finds all the elements with a “datePicker” class and removes the “hasDatepicker” class from the element. It then calls the datepicker method and binds the .datePicker class again.