Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery DatePicker Done button

Is there any way to handle the event of pressing the "done" button in jquery UI DatePicker?

I have a datepicker that allows only to choose between year and month as in here

The problem is that using the onclose event prevents me from clearing the field (if I click the datepicker pops up then if I close the current selected month and year are put into the field).

I would like not to use an additional "clear" button outside the datepicker, so I though I could use the Done button.

like image 989
MichelReap Avatar asked Mar 25 '13 16:03

MichelReap


1 Answers

I found solution on one forum (can't remember where - sorry). I know it's been a while, but for future search :)

Note: The change needs to be done in the plugin. You can simply search for "onClose:" to find it.

onClose: function (dateText, inst) {
    function isDonePressed() {
        return ($('#ui-datepicker-div').html().indexOf('ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all ui-state-hover') > -1);
    }
    if (isDonePressed()){
        alert('done pressed');
    }
}
like image 94
DrafFter Avatar answered Sep 22 '22 00:09

DrafFter