0

Is not working anybody tell me what i am doing wrong?I have code for cloned divs.in that div there 3 date pickers but not working when gets clone.getting cloned perfect but date picker is not working.

$(document).ready(function () {
var iCnt = 1; 

$('#btnadddd').on('click', function () {

clonedDiv.find('#datedeparturemulti').attr({id: 'datedeparturemulti'+iCnt, name: "date[]"});
clonedDiv.find('#datelchkinmulti').attr({id: 'datelchkinmulti'+iCnt, name: "late_checkin_date[]"});
clonedDiv.find('#datelchkoutmulti').attr({id: 'datelchkoutmulti'+iCnt, name: "late_checkout_date[]"});
addDate('datedeparturemulti'+iCnt);
addDate('datelchkinmulti'+iCnt);
addDate('datelchkoutmulti'+iCnt);

function addDate(id) { alert(id);
   $( "#"+id ).datepicker();
 }
});
  • we would need to see the code in order to help you! – Jeff Jul 29 '17 at 15:58
  • Need more information. What date picker are you using? How is it being instantiated on the elements? And how are you cloning the element, to where, so we can understand the scope of your request. Thanks – Cue Jul 29 '17 at 15:58
  • I removed the PHP tag from your question, since this is a javascript/jquery issue. – rickdenhaan Jul 29 '17 at 16:00
  • please paste your html and script code so that we can check and let you know. BTW i can guess two problem there:-1. same id used for multiple cloned date-picker elements. 2, event delegation is not used there – Alive to die - Anant Jul 29 '17 at 16:00
  • this might help: https://stackoverflow.com/questions/5788999/jquery-datepicker-on-cloned-elements?rq=1 – Jeff Jul 29 '17 at 16:02
  • Thank you. now i have added the code.please check what is wrong.thanks in advance. – user3262824 Jul 30 '17 at 07:52

1 Answers1

0

please try this,
Check the id of three date pickers. I think they are Same. May be that is the reason.

saifudeen ni
  • 145
  • 9