I am trying change link when a date is selected but whenever I select a date, I get
?day=
Here's my code:
Markup:
<i class="icon-calendar"></i>
It only works when I use input
<input type="text" class="datepicker">
Javascript:
$(document).ready(function(){
$(".datepicker").datepicker({
format: "yyyy-mm-dd",
endDate: "-2d"
})
.on('changeDate', function(ev){
var dateData = $('.datepicker').val();
window.location.href = "?day=" + dateData ;
});
});
Expected results: ?day=2013-11-01
Thanks
According to the documentation
you can get the formatted date with the format()
function accessible through the event object:
$(document).ready(function(){
$(".datepicker").datepicker({
format: "yyyy-mm-dd",
endDate: "-2d"
})
.on('changeDate', function(ev){
window.location.href = "?day=" + ev.format();
});
});
I'm pretty sure you can access the date via ev
:
$(document).ready(function(){
$(".datepicker").datepicker({
format: "yyyy-mm-dd",
endDate: "-2d"
})
.on('changeDate', function(ev){
var dateData = new Date(ev.date); // this is the change
window.location.href = "?day=" + dateData ;
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With