I have a datepicker whose max selectable date is six months in the future. And if I select a checkbox, the max selectable date can be any time in the future. I'm trying to do this with Knockout.js.
This would be my date picker input options:
<input id="newRequestStartDate"
type="text"
data-bind="sfDatePicker: request.startDate, sfDatePickerOptions: startDateOptions, disable: summaryHasInvalidDays()"
id="newTimeOffRequestStartDate"
class="sf-form-input"
data-range-group="ptoRange"
name="newTimeOffRequestStartDate"
/>
This would be my checkbox input:
<input type="checkbox"
id="globalOverrideCheckbox"
data-bind="checked: request.isGlobalOverride, disable: summaryHasInvalidDays()"
/>
I have a subscribe binding based on this:
self.request.isGlobalOverride.subscribe(self.updateMaxAllowableDateInFuture);
and the code for subscribable is:
this.updateMaxAllowableDateInFuture = (function (isGlobalOverrideSet) {
if (isGlobalOverrideSet) {
_maxAllowableDateInFuture = _dateTenYearsFromNow;
//this.startDateOptions.maxDate = _maxAllowableDateInFuture;
self.destroyDatePicker();
}
return _maxAllowableDateInFuture;
});