jQuery datepicker clone
Par PlaceOweb le dimanche, avril 17 2016, 22:39 - Javascript - Lien permanent
How to clone a jQuery UI Datepicker, and keep handler ?
I read several solution about cloning a datepicker jquery, but in my case, the datepicker source element is already loaded by the DOM and instanciate by jQuery UI.
I finaly solve it using :
var newID = $th.attr('id').replace(/\d+$/, function(str) { return parseInt(str) + 1; }); $th.attr('id', newID); // datepicker : remove icon (sibling/next) $th.next().remove(); // remove class : hasDatepicker $th.removeClass("hasDatepicker"); // add new datepicker $th.datepicker({ showOtherMonths: true, selectOtherMonths: true, showWeek: true, showAnim: '', showOn: "both", buttonImage: "calendar.gif", buttonImageOnly: true });
Ressources :