The function $.fn.dataTable.render.moment does not exist in npm package

I have encountered an issue with my application that I am struggling to solve: I want to format dates in my data table using Moment.js like I have done in the following script:

$().ready(function() {
    const FROM_PATTERN = 'YYYY-MM-DD HH:mm:ss.SSS';
    const TO_PATTERN   = 'DD/MM/YYYY HH:mm';

    // list of documents - INDEX 
    var listDocuments = $("#list-documents").DataTable({
        processing:true,
        serverSide:true,
        scrollY:620,
        autoWidth:true,
        pageLength:25,
        responsive:true,
        scroller: {
            loadingIndicator:true 
        },
        ajax: {
            url: $("#list-documents").attr('data-json')
        },
        columns: [
            {data:'nom',name:'nom'},
            {data:'uri',name:'uri',
            "fnCreatedCell": function(nTd,sData,oData,iRow,iCol) {
                $(nTd).html("<a href='" + oData.uri + "'>"+ oData.uri +"</a>")
            }
        },
            {data:'updated_at',name:'updated_at',
            render: $.fn.dataTable.render.moment(FROM_PATTERN,TO_PATTERN),
        },
            {data:'action',name:'action',orderable:false,searchable:false},
        ]
    })
    .on('draw',function() {
        $("[data-toggle='tooltip']").tooltip()
    })
})

The problem I am facing is the error message

$.fn.dataTable.render.moment is not a function
. I am using Laravel 8.54 with laravel-mix. Here is my app.js file where I load the libraries:

require('./bootstrap');

$('.toast').toast('show')

$(function () {
    $('[data-toggle="tooltip"]').tooltip()
})


window.$ = window.jQuery = require('jquery')
window.toastr = require('toastr')

require('moment')
require('../../node_modules/datatables.net/js/jquery.dataTables.js')
require('datetime-moment')
require('../../node_modules/datatables.net-bs4/js/dataTables.bootstrap4')
require('../../node_modules/jquery-ui/ui/widgets/autocomplete.js')
require('../../node_modules/jquery-ui/ui/widgets/sortable.js')
require('datatables.net-responsive')

I am reaching out for help because I have searched online but most solutions do not involve npm. Has anyone else encountered this issue before? Thank you in advance.

Answer №1

This code snippet is part of a plugin available on datatables.net

If you're interested, you can access it by following this link:

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for clearing a saved password in a browser using Angular.js and Javascript

There is an issue with the password and username fields in my Angular.js login page. When a user clicks on the 'remember me' option in their browser after logging in, the saved username and password are automatically displayed in the respective f ...

What is the process for implementing document.ondrop with Firefox?

I'm experiencing an issue where the document.ondrop function seems to be working in Chrome, but not in Firefox. Here's a link to an example demonstrating the problem: In the example, if you try to drop a file onto the page, it should trigger an ...

Switch up the color of checkboxes with a dropdown menu option

I have an HTML dropdown code and I am trying to trigger a click event when a specific value is selected. Once this value is clicked, I want some checkboxes to change color. <select> <option value="calculate">calculate</option> ...

A Step-by-Step Guide to Mocking a jQuery Function Using Jasmine in an Angular Directive Specification

When working with an angular directive, I am currently using $(element).fdatepicker(). How can I mock or stub this function in a jasmine test for the directive? If I don't stub it, I encounter the following error: TypeError: 'undefined' is ...

Having issues incorporating Redux into React Native application

Struggling to make a small app work in React Native with Redux. It was functioning fine without Redux, but after attempting to integrate Redux, it now shows a blank white screen and a loading message. I want to avoid using classes and stick to functional p ...

Unlock the Full Potential: Enabling Javascript's Superpowers through PHP Execution

I specialize in PHP and JavaScript. Currently, I am attempting to incorporate JavaScript functionalities into my PHP code. However, I am encountering an issue where the code is not functioning properly. The PHP code that executes the JavaScript code is as ...

When trying to convert to JSON in node, the process fails. However, the data can still be

I am currently working on converting an array to JSON in order to send it to a client. The data I see in the console is as follows: [ NL: [ true, true, true, true, true, true, true, true, true, true, true, true ], ...

My PHP script is not functioning correctly with Ajax

I am currently working with HTML5, PHP, and JavaScript. My goal is to implement Ajax in order to display the sizes of a selected product when an option is chosen from #productoSeleccionado. However, I believe that there may be an issue with my code as the ...

When an option is selected in one dropdown, a list is dynamically populated in another dropdown. However, the entire column then displays the selected row's options in a table format

https://i.stack.imgur.com/q7tMT.png Upon selecting an option from a dropdown within a table row, I make a call to an API to fetch a list of strings into another dropdown field for that specific row. However, the entire column is being populated with that r ...

What is the process for obtaining an API Key in order to access a service prior to authorization?

Alright, I have this app. It's a versatile one - can run on mobile devices or JavaScript platforms. Works across Windows, Apple, and Android systems. The app comes equipped with a logging API that requires an API key for operation. Specifically, befo ...

Improving Visibility in AngularJS

I am new to using Angular and encountering a simple issue. I have a button that, when clicked, should reveal a grid and some hidden filters. The filters are structured like this: <div ng-show="filtroFilial" style="visibility: hidden" class="col-md-2"&g ...

Triggering multiple functions by clicking on the Icon

I'm trying to execute two different functions when the user clicks on the Icon, but I keep getting an error that says: Expected onClick listener to be a function, instead got a value of object type. Can someone please help me figure out what I am doin ...

Modifying the Ext.js TreePanel checkbox component

I've implemented a basic tree panel checkbox example using Ext.js as shown below: Ext.onReady(function(){ var tree = new Ext.tree.TreePanel({ renderTo:'tree-div', title: 'My Task List', height: 300, ...

What methods can I use to get my kahoot botter to produce unpredictable answers?

After attempting to create a kahoot botter using the updated kahoot.js library, I came across this code snippet that supposedly answers random questions: const Kahoot = require("kahoot.js-updated"); var kahoots = [] for (var i = 0; i < bot_cou ...

Exploring VueJS Router History Mode with NGinx web server

After conducting research, I discovered several issues similar to the one I am facing. Currently, I have a docker-compose setup on Digital Ocean with NGinx, VueJS, and a Static Landing Page. Everything was working fine until I added a new route with a fo ...

Tips for efficiently storing and accessing data obtained from the "RESTBuilder" tool on the Total.js platform

After stumbling upon this informative tutorial on how to build a cryptocurrency comparison site with VueJs, I was inspired to create a single-page application using the total.js platform. My goal is to fetch the list of coins from the "coinmarketcap.com" A ...

Understanding the res.render method in JavaScript can be a bit tricky at first

In my spare time, I have been immersing myself in coding lessons and have encountered some puzzling aspects of the code: Firstly, there is a confusion surrounding the action attribute in HTML Secondly, this particular piece of code is causing me some b ...

Communication with child processes in node.js is not done using the child_process module

Hello Everyone, I'm currently experimenting with node.js to utilize JS plugins developed by others using the child_process API. However, I'm facing an issue where the child process is not able to communicate effectively with the parent process. ...

Maximum opacity in Three.js fog

My Current Endeavor: I am in the process of developing a lightweight GIS application with topography. One feature I want to implement is atmosphere haze. The Code I'm Working With: (Please bear with me as I have multiple scenes) fogColor = new T ...

Troubleshooting issue: Click function not responding inside Bootstrap modal

Below is the JavaScript code for my click function $(".addPizza").on("click", function(event) { event.preventDefault(); console.log("hello") let userId = $("#userId").attr("data-id"); let pizzaRecipe = $('#pizza-recipe').val().trim(); ...