Inflexibility with UI Datepicker: still limited to ready event with bottom script approach
Due to the usage of the document ready event
/* Initialise the date picker. */
$(document).ready(function() {
$.datepicker = new Datepicker(); // singleton instance
$(document.body).append($.datepicker._datepickerDiv).
mousedown($.datepicker._checkExternalClick);
});
the datepicker becomes inflexible in its usage. Using a bottom script approach (instead of DOM ready) still requires the ready event to initialize a datepicker on the page to prevent an error ($.datepicker has no properties).
Quickfixed it by moving the datepicker initialization into the datepicker method itself, although I may have overlooked the impact of this:
$.fn.datepicker = function(options){
/* Initialise the date picker if necessary. */
if (!$.datepicker) {
$.datepicker = new Datepicker(); // singleton instance
$(document.body).append($.datepicker._datepickerDiv).
mousedown($.datepicker._checkExternalClick);
}
var otherArgs = Array.prototype.slice.call(arguments, 1);
...
};
Change History (7)
Summary: |
Inflexibility with UI Datepicker: limited to window load event with bottom script approach →
Inflexibility with UI Datepicker: still limited to ready event with bottom script approach
|
Owner: |
changed from paul to iMarc
|
Resolution: |
→ fixed
|
Status: |
new →
closed
|
@Mark:
Klaus' recommend fix also resolves the issue I was having trying to use the $.datepicker() inside a div which has it's content loaded via AJAX. When the document.ready() method is used, errors are thrown. By initializing on first call, all issues are resolved.
-Dan