Stack Exchange
JQuery UI Date Picker sometimes opens blank web page
I'm using the JQuery UI Datepicker and when the code runs and the date picker is used it sometimes opens a blank web page. Any idea on how I can get this fixed?
var viewDashboardJobs = (function viewDashboardJobs() {

var _create = function _create() {

    var input09 = window.document.createElement("input");
    input09.setAttribute("id", "agency-brief-date");
    input09.setAttribute("type", "text");
    input09.setAttribute("name", "agency-brief-date");
    input09.setAttribute("title", "Please provide the agency brief date.");
    window.document.body.appendChild(input09);

    var agencyBriefDate = window.document.createElement("button");
    agencyBriefDate.setAttribute("type", "button");
    agencyBriefDate.setAttribute("onclick", "viewDashboardJobs.pickDate(document.querySelector('#agency-brief-date'));");
    agencyBriefDate.innerHTML = "Pick a date";
    window.document.body.appendChild(agencyBriefDate);

};

var _pickDate = function _pickDate(node) {    
    node.value = "";
    var id = "#" + node.id;    
    $(id).datepicker($.datepicker.regional['en']);
    $(id).datepicker("option", "dateFormat", "dd/mm/yy" );
    $(id).datepicker();
    $(id).datepicker("show");
    $(id).mouseover(function(e) {
        $(this).datepicker("destroy");
    });
};

return {
  create : _create,
  pickDate : _pickDate
}

})().create();


Can you provide a snippet for the same?

Not this function causes the problem, could you also post your form, or wherever you invoke the function?

The blank page is opened when you select a date on the date picker.

Can you provide a more complete working sample please

show the HTML where the datepicker is used. Check your network tab, see if something is causing a postback, or another request to be made (you didn't say if this blank page is in another tab or not)

The blank page is in the same tab.

ok. perhaps something is causing a page refresh. or it's actually blanking the content, or putting a white overlay on it, could be anything. Did you check the network tab like I suggested to see if it's definitely refreshing? And can you show the HTML where the datepicker is attached?

The page content is created using pure JavaScript.

@Berni Please post your HTML too. That may help a lot.

The HTML is in an IFRAME. The script calls a javascript file which creates all the HTML code.

it would still be helpful to see the HTML as it is rendered, to see if there are any problems, and for you to identify the element(s) to which the datepicker is assigned.

I've checked the date picker in a recent release and the reported issue no longer occurs. Thanks for the support everyone!
