Open guypaskar opened 9 years ago
I also posted this solution in issue #1000. Hopefully it works for you:
$("#datePicker.input-daterange").data("datepicker").pickers[0].setDate(new Date()); $("#datePicker.input-daterange").data("datepicker").pickers[1].setDate(new Date());
So on my cone it can look like this right?
$(".page-date-selection").data("datepicker").pickers[0].setDate(sDate); $(".page-date-selection").data("datepicker").pickers[1].setDate(eDate);
This did not work for me. The date was not selected even in the date picker (the right date was not displayed)
Yes, but the div containing the input dates should have the class: "input-daterange". Otherwise the datepicker doesn't know that it has to do something with a range.
Maybe that's not neccesarry when defining the inputs manually. $("#datePicker.input-daterange").datepicker({ ... inputs: $("#datePicker.input-daterange .input-group") });
Here is the div, it has input-daterange class.
I'm not sure I follow what you meant by Maybe that's not neccesarry when defining the inputs manually. $("#datePicker.input-daterange").datepicker({ ... inputs: $("#datePicker.input-daterange .input-group") });
The datepicker doesn't know if it has to render as a rangepicker. If you specify the class input-daterange, then it knows you're talking about a range. Otherwise you should specify the inputs manually like the code I mentioned.
Because it finds multiple input fields it also knows that it has to be a rangepicker.
I see. The parent div has input-daterange class.
So I tried the initial code and it did not work for me... did not even change the datepicker itself..
I made a jsfiddle, hopefully that helps.
thanks @arjenzwerver, works for me.
Works perfectly as described, this is exactly what I was looking for. Thanks!
and I init the daterange like this: $('.page-date-selection').datepicker( {showTime:true,autoclose:true} )
after that I do
$('#start-date').datepicker('update',someDateString); $('#end-date').datepicker('update' someDateString)
The pickers has the right values but I do not see the range selected within them. Only after I manually select a date on the date picker the range is being updated visually.
Any ideas?