Closed ndzeller closed 6 years ago
Please refer to #26 which is a similar ticket
@ghiscoding ,
I referred to the issue that you provided, and the initial load works as intended:
ViewModel
this.toDateOptions = {
format: 'MM/DD/YYYY',
minDate: this.fromDate,
useCurrent: false
};
View:
<abp-datetime-picker element.bind="toDatePickerElem" value.bind="toDate & validate" options.bind="toDateOptions"></abp-datetime-picker>
But when I try to update the value from an observable method of fromDate:
fromDateChanged(newValue, oldValue) {
if (this.toDatePickerElem) {
this.toDatePickerElem.methods.minDate(this.fromDate);
}
}
It does not update the UI, but instead clears out the minDate value (in this case I tried to set it to '11/06/2017'):
Am I misusing this line, or is it not working as intended?:
this.toDatePickerElem.methods.minDate(this.fromDate);
There's already an observable in the plugin itself (it's use for updating the model.bind
and value.bind
back and forth), so I'm wondering if that goes in conflict with your observables. I haven't tried it the way you describe so I can't really say and I'm not in front of any Aurelia code at the moment (Aurelia
is unfortunately only in my spare time since we use Angular
at work, so sad)
I found my problem after some debugging and the solution was a little embarrassing on my part. My fromDateOptions
variable had an extra Y at the end....
this.fromDateOptions = {
format: 'MM/DD/YYYYY',
maxDate: this.toDate,
useCurrent: false
};
so the date I was trying to set the minDate to was invalid (ex. '11/02/02017')
Thanks for your help and sorry for the confusion.
Awesome Aurelia plugin by the way!
Happy you found the solution :) If you like the plugin, you can also upvote it :star:
Have a nice upcoming weekend ;)
Hello,
I'm trying to represent a date range with a 'fromDate' and a 'toDate'. I'm using the
@bindable
attribute on each element property.When the fromDate is updated, I'm trying to set:
this.toDatePickerElem.methods.minDate(this.fromDate);
This is not updating the minDate in the 'toDate' datetimepicker. Additionally, if I set the minDate in the options, after I attempt the setter the minimum date in the UI is removed and I can select any date.
Am I using the minDate setter incorrectly, or is this a bug?
Thanks!