-
Notifications
You must be signed in to change notification settings - Fork 23
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
Binding problem with 1.0.2 #3
Comments
Yes I saw this problem after releasing it, that happens when not using an ISO format on the date. After seeing this, I was thinking that it might not have been the best to have 2 bindable attributes driving the picker. Perhaps we should only have 1 bindable attribute (the Here's a simple explanation with the code this.model = moment(e.date).toDate();
this.value = moment(e.date).format(format); The piece of code causing the issue is Any thoughts on what else we could do? I'm not sure if a valueConverter would really help in this case... don't think so |
Thinking more about this and I actually think that using valueConverter on your side would probably be the best thing to do. If you really want to use a format that is not an ISO format then use a value converter on the Something along the lines of <abp-datetime-picker value.bind="startdate | dateFormat: 'YYYY-MM-DD h:mm a'" format="YYYY-MM-DD h:mm"></abp-datetime-picker> value converter (code is actually coming from your first comment in previous issue) import * as moment from 'moment';
export class DateFormatValueConverter {
toView(value, format: string = "YYYY-MM-DD"): string {
return moment(value).format(format)
}
fromView(str: string, format: string = "YYYY-MM-DD"): Date {
return moment(str, format, true).isValid()
? moment(str, format).toDate()
: null;
}
} The value converter would only be used if you want a If you have better suggestions, please let me know. |
But when using only model.bind using a date object ("startdate") you shouldn't get this error I suppose?
|
The reason is because they affect each other. Changing |
In my ViewModel I have (I am not storing any string representation of the date at all)
and in my view I have
|
Hmm ok, I'm not sure if we can pass a let startdate: Date = new Date(2017, 1, 1);
console.log(moment(startdate)); Does it work or does it throw the ISO format warning? |
Trying the sample I made for Can you troubleshoot with Chrome and tell me where/how it fails? You could also try with my sample git clone https://github.com/ghiscoding/Aurelia-Bootstrap-Plugins
cd client-wp
npm install
npm start In the constructor, I have The only thing I might want to add in the plugin is a check on |
Any update on your issue? If not I'll eventually close the issue. Thanks |
Took some time to review this in the weekend and found the issue which was throwing a "moment ISO incorrect date format" message when the You might also be interested in my latest plugin. Thanks for your help and patience. :) |
Thank you. Got stuck with other projects so I didnt have time to respond,
sorry.
…On Mon, Apr 10, 2017 at 5:13 AM, Ghislain B. ***@***.***> wrote:
Took some time to review this in the weekend and found the issue which was
throwing a "moment ISO incorrect date format" message when the model.bind
is/was empty at the project creation. I had incorrect code to use moment()
with a null date which was causing the issue. Please update NPM to latest
version 1.0.3 of aurelia-bootstrap-datetimepicker
<https://www.npmjs.com/package/aurelia-bootstrap-datetimepicker>.
You might also be interested in my latest plugin.
Aurelia-Bootstrap-Select
<https://github.com/ghiscoding/Aurelia-Bootstrap-Plugins/tree/master/aurelia-bootstrap-select>
on NPM <https://www.npmjs.com/package/aurelia-bootstrap-select> / source
Bootstrap-Select <http://silviomoreto.github.io/bootstrap-select/>
Thanks for your help and patience. :)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AY8y3cuaFpAbkyuyvj2BQuPcYhjHh1jhks5ruZ5QgaJpZM4MtANv>
.
|
no problem, please give it a try and let me know if that fixes it ;) |
Just updated from 0.3.4 to v1.0.2 via npm. Both value.bind (which worked in 0.3.4)
<abp-datetime-picker value.bind="startdate | dateFormat"></abp-datetime-picker>
and model.bind
<abp-datetime-picker model.bind="startdate"></abp-datetime-picker>
yields this error (and browser hangs with 30% cpu):
Deprecation warning: value provided is not in a recognized ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info. Arguments: [0] _isAMomentObject: true, _isUTC: false, _useUTC: false, _l: undefined, _i: Invalid date, _f: undefined, _strict: undefined, _locale: [object Object] Error at Function.createFromInputFallback (http://localhost:9000/scripts/vendor-bundle.js:30109:668) at fb (http://localhost:9000/scripts/vendor-bundle.js:30232:129) at qb (http://localhost:9000/scripts/vendor-bundle.js:30298:413) at pb (http://localhost:9000/scripts/vendor-bundle.js:30298:274) at ob (http://localhost:9000/scripts/vendor-bundle.js:30296:274) at rb (http://localhost:9000/scripts/vendor-bundle.js:30303:160) at sb (http://localhost:9000/scripts/vendor-bundle.js:30303:194) at a (http://localhost:9000/scripts/vendor-bundle.js:30092:239) at AbpDatetimePickerCustomElement.valueChanged (http://localhost:9000/scripts/vendor-bundle.js:52618:43) at BehaviorPropertyObserver.selfSubscriber (http://localhost:9000/scripts/vendor-bundle.js:22755:48) at BehaviorPropertyObserver.call (http://localhost:9000/scripts/vendor-bundle.js:22621:14) at BehaviorPropertyObserver.setValue (http://localhost:9000/scripts/vendor-bundle.js:22601:18) at Binding.updateTarget (http://localhost:9000/scripts/vendor-bundle.js:11255:27) at Binding.call (http://localhost:9000/scripts/vendor-bundle.js:11270:16) at SetterObserver.callSubscribers (http://localhost:9000/scripts/vendor-bundle.js:6765:19) at SetterObserver.call (http://localhost:9000/scripts/vendor-bundle.js:10087:12)
The text was updated successfully, but these errors were encountered: