I am using datepicker. The usual way to bind an event, lets say for example, beforeShowDay
, would be:
$('.selector').datepicker({
beforeShowDay: function(date) { ... }
});
What I need is to bind the beforeShowDay
event after the calendar was rendered. So, let's say first I render the calendar:
$('.mySpecialContainer').datepicker({
//in this moment, for some reason, I am not allowed to bind nothing (that's not me who renders the calendar, that's why I am not allowed)
});
And then, if I try to bind something in the usual way:
$('.mySpecialContainer').datepicker({
beforeShowDay: function(date) { ... }
});
The calendar will be - of course - rendered again inside '.mySpecialContainer'
, instead of just binding the event. I have tried:
$('.mySpecialContainer').bind('beforeShowDay', function(date) { ... });
But that was just a desperate action :)
It doesn't make sense to me why you can't call bind
on that particular datepicker
event (or, for that matter, most datepicker
events). Most other jQueryUI widgets allow late-binding of events.
However, you can try the following. hasDatepicker
is applied to datepickers, and calling .datepicker
again on those elements is not reinitializing the widget, it's just modifying an option:
$('.hasDatepicker').datepicker("option", "beforeShowDay",
function(date) { ... });
$('.ui-datepicker-current-day').click();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With