PDA

View Full Version : datepicker calendar opens on dialog open



gib65
07-17-2015, 12:27 AM
Hello,

I'm having an issue with a datepicker. The problem is that when I open the dialog that contains the date picker, the calendar opens up right away. I want it to stay closed until the user clicks on the datepicker.

The first thing I do on the page, before the dialog is even open, is I convert the textbox in it to a jquery datepicker:

$("#DateOfIncidentTextbox").datepicker(
{
dateFormat: "DD, MM dd, yy"
}).attr("readonly", "readonly");

And then when the user opens the dialog, I open it like this:

$("#ConcernDialog").dialog(
{
modal: true,
draggable: true,
resizable: false,
title: title,
width: 1000,
"open": function (event, ui) {
$(".ui-dialog-titlebar-close").hide();
$("#lockedBy").remove();
$(".ui-dialog-titlebar").append(userLock); // 0.1 t)
$("#UploadFileButton").remove();
$(".ui-dialog-buttonpane").append("<input id='UploadFileButton' type='file' value='Upload File'>");
},
buttons:
{
"Cancel": function ()
{
$(this).dialog("close");
},
"Save": function ()
{
$(this).dialog("close");
}
}
});

The problem seems to be that the datepicker is the first item capable of having focus, so the dialog gives it the focus. This, of course, causes it to open the calendar.

Is there a way to suppress the opening of the calendar? Or preventing the datepicker from getting the focus? I tried doing a whole bunch of things in the open event, like setting the display to none, or calling hide() on the calendar, but none of that works (actually, some of that works, like setting the visibility to "hidden" but then I can't open the calendar again). Can anyone help me?