New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to pre-select time with data-start-time #163
Comments
Hi, I think it's a bug. I'll have a look on it. |
I have the same problem with daterange, I can't set startDate and endDate using setters. |
same problem, cannot pre set startDate and endDate
or as options
or via the setters
am i doing something wrong? how do i set the default start date for the calendar |
Anyone is doing anything wrong. It's a bug. I'm working on it. |
I'm encountering the same issue while attempting to set |
Hi, someone knows a workaround for this? i was trying several ideas with no luck. |
Hi, reviewing it in detail, the doc is wrong, to init time you must use properties: start and end, both are Date |
Same here. Has anyone found a work around? |
as davidgil mentioned, the docs are wrong, enter it with your startDate... the following in options worked for me: let calendars = bulmaCalendar.attach('[type="datetime"]', But that doesn't help if you have isRange: true..... I can't get it set the proper start time for a date range. |
Found a way around the isRange: true bit JAVASCRIPT:
|
Same issue on Vue JS: /**
* Init custom datetime picker from Bulma
*/
initDateTimePicker: function () {
var now = new Date()
console.log(moment(now).format('HH:mm'))
const calendar = bulmaCalendar.attach(this.$refs.calendarTrigger, {
type: 'datetime',
dateFormat: 'YYYY-MM-DD',
timeFormat: 'HH:mm',
startDate: moment(now).format('YYYY-MM-DD'),
startTime: moment(now).format('HH:mm'),
showHeader: false,
showButtons: false,
showFooter: false,
displayMode: 'dialog'
})[0]
calendar.on('select',date => {
console.log(date.data.value())
});
} Any workaround? |
Hi guys, I've been fighting with this bug as well. Maybe you'll find useful my hacky-from-non-js-dev function. function fixPrefilledDateTime (calendar) {
if (options.startDate != null) {
const hours = options.startDate.getHours();
const minutes = options.startDate.getMinutes();
// set value
if (calendar.timePicker._time.start != null) {
calendar.timePicker._time.start = options.startDate;
}
// set ui
if (calendar.timePicker._ui.start.hours.number != null && calendar.timePicker._ui.start.minutes.number != null) {
calendar.timePicker._ui.start.hours.number.innerHTML = hours;
calendar.timePicker._ui.start.minutes.number.innerHTML = minutes;
}
}
if (options.endDate != null) {
const hours = options.endDate.getHours();
const minutes = options.endDate.getMinutes();
// set value
if (calendar.timePicker._time.end != null) {
calendar.timePicker._time.end = options.endDate;
}
// set ui
if (calendar.timePicker._ui.end.hours.number != null && calendar.timePicker._ui.end.minutes.number != null) {
calendar.timePicker._ui.end.hours.number.innerHTML = hours;
calendar.timePicker._ui.end.minutes.number.innerHTML = minutes;
}
}
calendar.refresh();
} |
Urgh, wish I'd seen this ticket before using this control. It's been open since last year and causes a fundamental break. There really should be a warning about this on the bulma site if it's not fit for us atm. 😠 |
Unbelievable that this continues without work... after 1 year and a half... |
I second the above comment - basic functionality completely broken |
All the people complaining that this doesn't work can create a pull request to fix it, it's open source after all. |
Same issue here. |
Should be fixed with 6.1.2 |
@michael-hack what was the fix? I've checked 6.1.2 file changes, but I can't resolve where the fix is implemented. Thanks :) |
@DebugTheCode I've made a lot of changes in the last days. It can also be in the changes from 6.1.0 to 6.1.1. As you can see in the docs (https://doc.mh-s.de/bulma-calendar/demonstration/datetime/#range-selection) the preset start / end date and time is set: |
I am on v6.1.7 but still data-start-time="14:00" makes no difference to me? What is the expected input? Does it need a datetime value? |
No, it can be a datetime, but a string is also ok if it has the same format as configured under dateFormat / timeFormat. If it is a datetime field, there must also be a data-start-date, otherwise no value will be displayed. With a pure time field data-start-time is sufficient. Can you maybe show us a short snippet? |
Sure, this is how I have set it up:
All of the other parameters are taken into consideration but the startTime. (File is a pug-template file) |
Thanks, it's the missing "data-start-date" for a datetime field, add data-start-date="01/07/2021" and it should work. I'll change that someday, that you can also just specify the time at a datetime. |
I'm not able to initilize / pre-select the time with data-attributes.
<input type="time" data-start-time="10:00" value="10:00" name="start_time" id="start_time" >
The form looks fine and I can select a time but initializing it beforehand does not work with a time of my choosing. Is it a bug or am I doing it wrong?
I'm on the latest bulma-calender release which i believe is 6.0.4
The text was updated successfully, but these errors were encountered: