Jake B.
Well-known member
We've just come across an issue in a custom add-on we did for someone quite some time ago where we used the following JavaScript to enable Pikaday's time picker functionality:
However, when upgrading from 2.0.x to 2.1.5a this feature broke, we've tracked it down to being broken in 2.1.3 and working in 2.1.2 but I cannot quite determine what exactly changed. Dumping
@Chris D is there a recommended approach to make changes to the pikaday config in a cleaner manner than this? It's got quite a few built in features that would be useful, but currently don't seem to have a clean way to enable them
JavaScript:
window.addEventListener("load", function(event) {
$(document).ready(function() {
var $config = {
showTime: true,
i18n: {
previousMonth : '',
nextMonth : '',
weekdays : [0, 1, 2, 3, 4, 5, 6].map(function(day){ return XF.phrase('day' + day) }),
weekdaysShort : [0, 1, 2, 3, 4, 5, 6].map(function(day){ return XF.phrase('dayShort' + day) }),
months : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].map(function(month){ return XF.phrase('month' + month) }),
midnight: 'Midnight',
noon: 'Noon'
},
onSelect: function() {
var pad = function(number) {
if (number < 10) { return '0' + number; }
return number;
};
var date = this._d,
day = String(date.getDate()),
month = String(date.getMonth() + 1),
year = String(date.getFullYear()),
hour = String(date.getHours()),
minute = String(date.getMinutes());
$(this._o.field).val(year + '-' + pad(month) + '-' + pad(day) + ' ' + pad(hour) + ':' + pad(minute));
}
};
$.each($('.datetime'), function() {
$(this).data('pikaday').config($config);
});
});
});
However, when upgrading from 2.0.x to 2.1.5a this feature broke, we've tracked it down to being broken in 2.1.3 and working in 2.1.2 but I cannot quite determine what exactly changed. Dumping
$(this).data('pikaday')
is now returning undefined
when in 2.1.2 it did not.@Chris D is there a recommended approach to make changes to the pikaday config in a cleaner manner than this? It's got quite a few built in features that would be useful, but currently don't seem to have a clean way to enable them