I had to modify the existing datepicker because I was getting similar complaints. The main complaint was that if you opened the datepicker and it appeared too low on screen (and you had to scroll down to view it), it would disappear. But only if you used your scroll wheel, or something like that. It was DEFINITELY due to quirks mode.
Here's the code I use instead. Sorry it's not "nicely packaged" as a jquery plugin. I haven't gotten around to it yet. Just change the selector from ".datePicker" to whatever class you're using for your date pickers. I'm also using an open button called "button-calendar.gif" that gets written next to the text box. You'll have to point it to your own button.
If this code doesn't work for you, let me know and I'll make it a bit more portable. Call it from your document.ready function.
function initializeDatePicker()
{
// - show/hide without disrupting the page flow.
$(".datePicker").each(function ()
{
var dpInitClass = "datePickerInitialized";
var hasDatePicker = $(this).hasClass(dpInitClass);
if (hasDatePicker)
return false;
// tighten up the width while we're here to make room for the "close" button:
$(this).css("width", "100");
$(this).css("padding-right", "50");
// the id of the input with the class datePicker, and its jquery selector:
var thisId =
this.id;
var altFieldId = "#" + thisId;
// only write the html once:
if ($("#datePickerFor_" + thisId).length == 0)
{
// insert a div for the datepicker so that it shows up inline, and insert a close button.
// both are set display:none until click fires on the input text box.
$(this).after("<div class='datePickerFor' target='" + thisId + "' id='datePickerFor_" + thisId + "' style='display:none; position:absolute'></div>");
$(this).after("<input type=\"button\" onclick=\"$('#datePickerFor_" + thisId + "').hide();$('#datePickerCloseFor_" + thisId + "').hide();$('#datePickerOpenFor_" + thisId + "').show();\" id=\"datePickerCloseFor_" + thisId + "\" style=\"display:none;\" value=\"Close\">");
// insert an image button that opens the datepicker onclick:
$(this).after("<img id=\"datePickerOpenFor_" + thisId + "\" src=\"button-calendar.gif\" style=\"cursor:pointer\" />");
}
// show the inline datepicker and the close button and hide the calendar button image onclick:
$(this).click(function ()
{
// set the div to a datepicker with an onselect event that closes both the div and the close button.
// the value of the input text box is set by specifying the "altField" property.
// the date should be set to whatever is in the text box, or the current date if no value.
$("#datePickerFor_" + thisId).datepicker({
showButtonPanel: false,
numberOfMonths: 1,
minDate: new Date,
defaultDate: $(altFieldId).val(),
onSelect: function (dateText, instr)
{
$(this).hide();
var targetId = $(this).attr("target");
$(altFieldId).val(dateText);
$("#datePickerCloseFor_" + targetId).hide();
$("#datePickerOpenFor_" + targetId).show();
}
});
var pos = $(this).position();
var posTop = pos.top + $(this).height() + 10;
var posLeft = pos.left;
$("#datePickerFor_" + thisId).css("top", posTop);
$("#datePickerFor_" + thisId).css("left", posLeft);
$("#datePickerOpenFor_" + thisId).hide();
$("#datePickerFor_" + thisId).show();
$("#datePickerCloseFor_" + thisId).show();
});
// so that we know this datepicker is initialized. code at top only runs if datepicker isn't yet initialized.
$(this).addClass(dpInitClass);
// call text input's onclick when the calendar button is clicked:
$("#datePickerOpenFor_" + thisId).click(function ()
{
$("#" + thisId).trigger("click");
});
// default today's date:
var todaysDate = new Date();
$(this).val(todaysDate.getMonth() + 1 + "/" + todaysDate.getDate() + "/" + todaysDate.getFullYear());
});
}
________________________________
--
You received this message because you are subscribed to the Google Groups "HEO iForms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
heo-iforms+...@googlegroups.com.
To post to this group, send email to
heo-i...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msg/heo-iforms/-/Y9OZ3GdoAV4J.
For more options, visit
https://groups.google.com/groups/opt_out.