I’m updating a JQuery datepicker with Ajax and have to reinitialize the datepicker each time, but the date is automatically set to the current date rather than the selected date. How do I change my code to pass the correct date?
I’m currently trying to use a Rails method like (params[:start_time].to_datetime).month for the year/month/day, but I keep getting errors when I apply it to new Date()
Index.js
$('#datepicker').datepicker(
{
dateFormat: 'yy-mm-dd',
onSelect: function(dateText) {
$.getScript(document.location.href + '&start_time=' + dateText, function(data) {
});
}
});
$('#datepicker3').datepicker("setDate", new Date(2008,9,03) );
Okay, your problem seems to be converting date formats from a string to a ruby object, then to a javascript object.
Try doing something like this: