I am using Timepicker for jQuery user Trent Richardson. I know that the plugin has been modified to override $ .datepicker._selectDate so that the selector remains open when the date is selected. It's great.
However, I was asked to close the collector by double-clicking the date. Everything else remains unchanged, including a button to close the collector when this is done, etc., only they want the double click to work as well.
I tried to associate a double-click event with calendar dates in several ways (basically the options $('.ui-datepicker-calendar a').bind('dblclick', function () {/*do something*/});)- indeed, I also tried to associate other events - and nothing works. I tried the sentences sent for How to close a DateTimePicker with a double-click without joy.
Is it possible? Do I need to change the onSelect function to distinguish between click and double click? (And how, when event.typeis undefined?) Am I attached to the wrong element? (I tried to tie in the $('.ui-datepicker-calendar a'), $('#ui-datepicker-div'), $('#ui-datepicker-div .ui-datepicker-calendar a')and many other options.)
For completeness, here is my code:
$('#date-range-from, #date-range-to').datetimepicker({
changeYear: true,
changeMonth: true,
controlType: 'select',
dateFormat: 'M dd, yy ',
minDate: 'Jan 01, 2010 ',
maxDate: 'Dec 31, xxxx '.replace('xxxx', new Date().getFullYear() + 1),
showAnim: '',
showMinute: false,
showOtherMonths: true,
showTime: false
}).on('change', function () {
var t = $(this),
date = t.val().slice(0, 12),
fromto = t.attr('id').replace('date-range-', ''),
time = t.val().slice(-5);
dashboardOpts.dateRange[fromto].date = date;
dashboardOpts.dateRange[fromto].time = time;
}).mousedown(function () {
$('#ui-datepicker-div').toggle();
$(this).blur();
});
$('#ui-datepicker-div .ui-datepicker-calendar a').bind('dblclick', function () {
console.log('I just want to see if this event can be bound!');
});
Thanks in advance for your help!
Edit: To clarify, “options ... .bind('dblclick', ...)” I meant that I tried .live('dblclick', ...)(although I know that it is out of date) and $(element).on('dblclick', ...)and $(document).on('dblclick', element, ...).
I also tried .stopPropagation()and .stopImmediatePropagation()although I do not think this is a distribution problem.
I believe there is something in the datetimepicker plugin code that captures events on the calendar. Unfortunately, I could not find it yet. Any insight is greatly appreciated!