How to close a DateTimePicker with a double click

I am using jQuery DateTimePicker addon (By: Trent Richardson ) and it will only close after you select the date and time. However, some users do not care about the time, and they want the calendar to close after they select only the date.

I managed to close the Calendar after selecting the date, but I need to implement a double click, not one click. How should I do it? Here is my code:

$(jqCompletedEndID).datetimepicker({  
    ampm: true, 
    onSelect: function(){
       $(this).datepicker("hide"); $(this).blur();
    }
});

I know there is a dblclick event in javascript, but not sure how to apply it in this context.

Thank!

+3
source share
3 answers

/. - Alex, , datetimepicker, , , ( , , ), dblclick .

, , . datetimepicker onSelect :

(, ._ $- jQuery )

this._$input.datetimepicker({
...
onSelect: function() {
    var self = this;
    setTimeout(
            function () {
                $('.ui-datepicker-current-day').bind('click', function () { self._$input.datepicker('hide'); });
                $('.ui-datepicker-current-day').bind('dblclick', function () { self._$input.datepicker('hide'); });
            },
            0
        );
}

, , , , . , Chrome, FireFox, Safari Opera "click", IE "dblclick". , setTimeout, , , , , .

, , , , , . ( beforeShow, , ). , , , , , , .

+1

...

$('#datepicker').datepicker({
     //...
});


$('table.ui-datepicker-calendar a').bind('dblclick', function() {
   $('#datepicker').val();
});
0

You can add an event handler doubleclickto the html tag itself. You will have an emtpy div for datepicker, so change it as

<div id="datepicker" ondblclick="close()"></div>

In the function, close()write code to hide the datepickerdiv.

0
source

All Articles