Uncaught ReferenceError: DateTime is not defined

Uncaught ReferenceError: DateTime is not defined

LupusMichaelisLupusMichaelis Posts: 4Questions: 0Answers: 0

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

  • tangerinetangerine Posts: 3,342Questions: 35Answers: 394

    You need to be including the DateTime extension.
    https://datatables.net/extensions/datetime/index#Features

  • LupusMichaelisLupusMichaelis Posts: 4Questions: 0Answers: 0

    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 read dt, you would agress it's pretty confusing :confused:

    I 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:

    $ bower search datatables.net-datetime
    Search results:
    
        datatables.net https://github.com/DataTables/Dist-DataTables.git
        datatables.net-dt https://github.com/DataTables/Dist-DataTables-DataTables.git
        datatables.net-translations https://github.com/nelson6e65/datatables.net-translations.git
        datatables.net-tranlations https://github.com/sidneysouza/datatables.net-translations.git
        datatables-datetime-moment https://github.com/Marchrius/datatables-datetime-moment.git
        DataTables https://github.com/DataTables/DataTables.git
        datatables https://github.com/DataTables/DataTables.git
        datatables.net-select-dt https://github.com/DataTables/Dist-DataTables-Select-DataTables.git
    … (many more result)
    
    

    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?

  • allanallan Posts: 61,431Questions: 1Answers: 10,048 Site admin

    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

  • allanallan Posts: 61,431Questions: 1Answers: 10,048 Site admin

    Oh. Apparently it isn't possible to publish to Bower any longer from their docs:

    As Bower is deprecated, registering new Bower packages is not supported anymore.

    Npm it is then :)

    Allan

  • LupusMichaelisLupusMichaelis Posts: 4Questions: 0Answers: 0

    I just did npm install --save datatables.net-datetime then expected the Datetime 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 :relaxed:

  • allanallan Posts: 61,431Questions: 1Answers: 10,048 Site admin

    then expected the Datetime from the DataTables renderer would magically find its friend

    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

  • LupusMichaelisLupusMichaelis Posts: 4Questions: 0Answers: 0

    Well, DataTables/Plugins/dataRender/datetime.js does not import it (and my understanding, expects DateTime 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 ^^

  • allanallan Posts: 61,431Questions: 1Answers: 10,048 Site admin

    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

Sign In or Register to comment.