Date not cycling properly
Closed this issue · 5 comments
This is similar to this error however, I have a code where we duplicate the values from a previous date-paired object, I then reinitialize the datepair script, however my error occurs when I change the start date. When I change the start date, the end date duplicates the same day, rather than +1, despite the time being the next day.
Here's my code that I use
$(".dates").datepair('remove'); $("form[data-shift-count='"+(form_id+1)+"'] .new_indiv_shift_single_location").val(loc_val).trigger('change'); $("form[data-shift-count='"+(form_id+1)+"'] .new_indiv_shift_single_employee_req").val(emp_val).trigger('change'); $("form[data-shift-count='"+(form_id+1)+"'] .date.start").val(ds_val).trigger('change'); $("form[data-shift-count='"+(form_id+1)+"'] .date.end").val(de_val).trigger('change'); $("form[data-shift-count='"+(form_id+1)+"'] .time.start").val(ts_val).trigger('change'); $("form[data-shift-count='"+(form_id+1)+"'] .time.end").val(te_val).trigger('change'); $("form[data-shift-count='"+(form_id+1)+"'] .caller").val(cal_val).trigger('change'); $("form[data-shift-count='"+(form_id+1)+"'] .comments").val(com_val).trigger('change'); $(".dates").datepair();
What's happening here is im creating a new object through javascript, and inputting values from the previous form into the new created object. Everything works perfectly, EXCEPT when I change the new element's start date, and the re-initialized datepair does not recognize that the end-time is into the next day.
I hope this makes sense, I for some reason cannot make a fiddle.
I think removing the script and then initializing it again is what causes this error.
I wish I could help - this is complicated enough that I need to see a working example in order to debug.
https://jsfiddle.net/Wimbledon/4z5gys2L/69/ Here's the fiddle
In the jsfiddle it looks like the inputs are all being placed into one div. Datepair.js needs the inputs to be grouped into separate containers.
https://jsfiddle.net/Wimbledon/4z5gys2L/75/ Here we see 'getTime' error in the console log when applying to separate containers