-
-
Notifications
You must be signed in to change notification settings - Fork 184
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
Can't change time dynamically #153
Comments
you exposed some serious shortcomings that I'll have to look into. // when the date picker is shown
onOpen: function() {
// when clicking on any of the cells of the day picker
// (we set a single delegated event handler)
// notice the use of namespace making it easier to remove it later on
$('.Zebra_DatePicker .dp_daypicker').on('click.Zebra_DatePicker', 'td', function() {
var $element = $(this),
date = new Date($element.data('date')),
day = date.getDay(),
enabled_hours = [], i;
// if the cell is not disabled, nor it is a weekend day
if (!$element.hasClass('dp_disabled') && !$element.hasClass('dp_weekend')) {
// set enabled hours
for (i = 8; i <= (day >= 1 && day <= 4 ? 16 : 14); i++)
enabled_hours.push(i);
// update date picker
$('#id_begin').data('Zebra_DatePicker').update({
enabled_hours: enabled_hours
});
}
});
},
// when the date picker is closed we need to remove the event handler
// notice the use of the namespace making it easier to remove
onClose: function() {
$('.Zebra_DatePicker .dp_daypicker').off('click.Zebra_DatePicker');
} you should also disable weekend days (see the docs) and handle the situation when the time view is accessed without previously selecting a day let me know if it works |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi :)
I tried now for hours to change the time according to a selected day (opening hours: Monday-Thursday: 8am-4:30pm, Friday: 8am-2:30pm), but I'm not able to.
First I tried the onChange Event with selecting the "time" view, but there I have not the day which I had selected before (or am I missing something?).
Now I made a hack around it, but I'm not happy with this.
I use the onChange Event now with selecting the "days" view and override all day click events (which is the problem) to change the time range with the update function. But when I select the day my click function triggers correctly, but the view does not change to "time" (because of overriding the click event of Zebra_Datepicker) and i have to click again on the day (or another, doesn't matter then)
Here is my code:
And another topic:
Would be also awesome to have the possibility to set the start time and end time (e.g. 8am-4:30pm, now I only can set the enabled_minutes to [0, 30] but that's not the best solution for this.
Thanks in advance,
cheers,
Michael
The text was updated successfully, but these errors were encountered: