mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Datepicker: reinitialize datepicker if mainDiv isn't on the page. Fixed #5679 - Datepicker should reinitialize if dpDiv is removed
This commit is contained in:
parent
cf9fbce139
commit
7ffcaa2e3b
@ -6,6 +6,16 @@
|
|||||||
|
|
||||||
module("datepicker: core");
|
module("datepicker: core");
|
||||||
|
|
||||||
|
test("initialization - Reinitialization after body had been emptied.", function() {
|
||||||
|
expect( 1 );
|
||||||
|
var bodyContent = $('body').children(), inp = $("#inp");
|
||||||
|
$("#inp").datepicker();
|
||||||
|
$('body').empty().append(inp);
|
||||||
|
$("#inp").datepicker();
|
||||||
|
ok( $("#"+$.datepicker._mainDivId).length===1, "Datepicker container added" );
|
||||||
|
$('body').empty().append(bodyContent); // Returning to initial state for later tests
|
||||||
|
});
|
||||||
|
|
||||||
test( "widget method - empty collection", function() {
|
test( "widget method - empty collection", function() {
|
||||||
expect( 1 );
|
expect( 1 );
|
||||||
$( "#nonExist" ).datepicker(); // should create nothing
|
$( "#nonExist" ).datepicker(); // should create nothing
|
||||||
|
8
ui/jquery.ui.datepicker.js
vendored
8
ui/jquery.ui.datepicker.js
vendored
@ -2023,11 +2023,15 @@ $.fn.datepicker = function(options){
|
|||||||
|
|
||||||
/* Initialise the date picker. */
|
/* Initialise the date picker. */
|
||||||
if (!$.datepicker.initialized) {
|
if (!$.datepicker.initialized) {
|
||||||
$(document).mousedown($.datepicker._checkExternalClick).
|
$(document).mousedown($.datepicker._checkExternalClick);
|
||||||
find(document.body).append($.datepicker.dpDiv);
|
|
||||||
$.datepicker.initialized = true;
|
$.datepicker.initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Append datepicker main container to body if not exist. */
|
||||||
|
if ($("#"+$.datepicker._mainDivId).length === 0) {
|
||||||
|
$('body').append($.datepicker.dpDiv);
|
||||||
|
}
|
||||||
|
|
||||||
var otherArgs = Array.prototype.slice.call(arguments, 1);
|
var otherArgs = Array.prototype.slice.call(arguments, 1);
|
||||||
if (typeof options === 'string' && (options === 'isDisabled' || options === 'getDate' || options === 'widget')) {
|
if (typeof options === 'string' && (options === 'isDisabled' || options === 'getDate' || options === 'widget')) {
|
||||||
return $.datepicker['_' + options + 'Datepicker'].
|
return $.datepicker['_' + options + 'Datepicker'].
|
||||||
|
Loading…
Reference in New Issue
Block a user