Reputation: 1781
I would like a datepicker like the one found here:
I am using the jquery ui datepicker with much success. I am showing 2 months at a time just like the one in the link but I would like it to animate with a slide when I click the next/prev month buttons.
I have tried this but it animates the entire datepicker, i.e. the entire datepicker slides out then back in again.
onChangeMonthYear: (year, month, inst): void => {
$('.ui-datepicker')
.hide('slide', { direction: 'right' }, 300)
.show('slide', { direction: 'left' }, 300);
}
here is a fiddle:
SOLVED thanks to AB Udhay. I removed the onChangeMonthYear function and put this in the contructor(using TypeScript):
$(document).on('click', '.ui-datepicker-next', () => {
$('.ui-datepicker-calendar')
.hide('slide', { direction: 'left' }, 200)
.show('slide', { direction: 'right' }, 200);
});
$(document).on('click', '.ui-datepicker-prev', () => {
$('.ui-datepicker-calendar')
.hide('slide', { direction: 'right' }, 200)
.show('slide', { direction: 'left' }, 200);
});
Upvotes: 0
Views: 869
Reputation: 753
"onChangeMonthYear" method will trigger after the date and month has changed. So you do something like this on click of the buttons.
$(document).on('click', '.ui-datepicker-next', function () {
$(".ui-datepicker-title>span").hide().show(300);
$(".ui-datepicker-calendar").hide('slide', { direction: 'right' }, 300).show('slide', { direction: 'left' }, 300)
})
$(document).on('click', '.ui-datepicker-prev', function () {
$(".ui-datepicker-title>span").hide().show(300);
$(".ui-datepicker-calendar").hide('slide', { direction: 'left' }, 300).show('slide', { direction: 'right' }, 300)
})
Upvotes: 1