Uncaught ReferenceError: DateTime is not defined
Uncaught ReferenceError: DateTime is not defined
Hi everyone,
I'm using those plugins in an Ember project using Bower to handle dependencies.
I've been charged with improving de deployment of the app and that lead me to rebuild the project again and again in a pristine environment.
This made me encounter a problem that no one in my team faced yet: the return of a DateTime (whatever it is in JS). The breaking change was introduced here: https://github.com/DataTables/Plugins/blame/950f84e173883900ed139b933de120ad0de5617b/dataRender/datetime.js#L132
I “resolved” the issue by fixing the version to the one preceding this commit (1.13.2).
I don't understand what was the intent of the commit, so I don't know if it's a bug or a feature!
If this is intended, what dependency am I lacking?
(if required, I may provide an example that showcases the issue)
Thanks for your help!
Replies
You need to be including the DateTime extension.
https://datatables.net/extensions/datetime/index#Features
Thanks for the hint, unfortunately I did stumble over this documentation, but it doesn't make much sense to me. I agree that I have the additional problem to be using bower.
To top that, I'm fairly inferring
DateTime
every time I readdt
, you would agress it's pretty confusingI attempted to install the package as an npm resource but to no avail with the command provided in the documentation. The reference still isn't resolved.
As for bower:
I don't see any package that could help me.
(Moment is already a dependency on this project, so it isn't missing per se)
Should I attempt to create a package for bower that is similar to the one that is distributed through NPM?
I'll do that - it should be something that I can publish to. Thanks for the offer though.
Can you show me the NPM commands you used and then how you used the software (i.e. your imports, etc).
If there is an error in the docs, I'd like to correct that.
Thanks,
Allan
Oh. Apparently it isn't possible to publish to Bower any longer from their docs:
Npm it is then
Allan
I just did
npm install --save datatables.net-datetime
then expected theDatetime
from the DataTables renderer would magically find its friend. I didn't dig furthermore as I didn't know if I was heading toward lava or diamond ^^For bower that's a bummer, I didn't know it existed until I worked on this legacy project. I guess your good for removing any reference of bower within the doc!
I'll have to talk with my colleagues about that.
Thank you for all the help, I'll come back for my next problem
It would if you added
import DateTime from 'datatables.net-datetime';
to your code. At least that's the theory. But just installing the package isn't enough, you then need to reference it in your code.Allan
Well,
DataTables/Plugins/dataRender/datetime.js
does not import it (and my understanding, expectsDateTime
to be available globally. Hence magic.I wouldn't know yet how to tell Ember to load that type for the whole project, I imagine it's the way to go. I'll see that later ^^
I guess the first thing to ask is how you are currently importing DataTables into your application? It would register globally if you just embedded the CDN script tag, but I'm guessing you aren't doing that since you are using NPM.
Allan