Issue with Date sort

Issue with Date sort

nazenaze Posts: 18Questions: 4Answers: 0

Link to test case:
https://codesandbox.io/s/create-and-use-environment-variable-in-nextjs-forked-vn4goh?file=/components/table/myTable.js
Debugger code (debug.datatables.net):
Error messages shown:
TypeError: jquery__WEBPACK_IMPORTED_MODULE_3___default(...).fn.dataTable.moment is not a function

Description of problem:
I am currently using next.js, I am not sure how to import the moment library other than adding the Script and using the import statement. I need it to make the date work in my actual project. The date format is different from the date format used in the example link.

Answers

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin

    Normally you would do something like:

    DataTable(window, $);
    

    Since the DataTable export in a CommonJS environment is a function.

    However, that isn't the whole story here. In fact I can't get the example to run the code in myTable.js at all: https://codesandbox.io/s/create-and-use-environment-variable-in-nextjs-forked-v1fwu2?file=/components/table/myTable.js:615-636

    I'm probably missing something, but I'm not sure what it is!

    There is also something a bit odd in that there was Script tags to include DataTables and jQuery as well as the import statements. I'm not sure what the intention was there?

    Allan

  • nazenaze Posts: 18Questions: 4Answers: 0

    I made some updates to your code base. It is weird in this case. I am not sure how the sandbox is set up. It is requiring both the script and the import to be present. If you look at it again, there is an error with the moment.js not being defined. That is the only issue at the moment.

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin

    Did you save your changes to a fork?

Sign In or Register to comment.