I'm using the 4.17.37 of Bootstrap 3 Datepicker - eonasdan datepicker
I have an inline datepicker correctly showed and I would only the days mode, so I use the following code, but the events dp.show and dp.update are not fired.
$('#datetimepicker').datetimepicker({
inline: true,
format: 'DD/MM/YYYY'
}).on('dp.show dp.update', function () {
$(".datepicker-days").find("th").eq(1).removeAttr('title')
.css('cursor', 'default')
.css('background', 'inherit').on('click', function (e) {
e.stopPropagation();
});
});
EDIT 1
I tried also with dp.change (and show.dp, update.dp, change.dp too).
If the datepicker is not inline the events are fired.
EDIT 2
I'm using:
EDIT 3
The same issue with version 4.17.42
The issue is that the dp.show
event doesn't trigger when the widget is inline.
According to plugin documentation, the dp.show
event is only emitted from toggle()
or show()
functions, but only if the widget was hidden before the call.
So my solution is a little bit dirty, but I think that it solves your problem. You can call hide()
and show()
functions immediately after widget initialization.
$('#datetimepicker').datetimepicker({
inline: true,
format: 'DD/MM/YYYY'
}).on('dp.show dp.change', function () {
// console.log('dp.show or dp.change event');
$(".datepicker-days").find("th").eq(1)
.removeAttr('title')
.css('cursor', 'default')
.css('background', 'inherit')
.on('click', function (e) {
e.stopPropagation();
});
});
$('#datetimepicker').data("DateTimePicker").hide();
$('#datetimepicker').data("DateTimePicker").show();
Fiddle here: https://jsfiddle.net/zeudzqe1/.
Any further improvement of this response is welcomed.