Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

252
Vistas
$.fn.dataTable.render.moment is not a function with npm

I got a basic issue in my application that i can't solve : i would like to format date in my datatable using moment like i have done in this script :

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

    // liste des 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 had is that i got this error $.fn.dataTable.render.moment is not a function. I'm using Laravel 8.54 with laravel-mix. Here is my app.js 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'm asking here because i saw many subjects treating this issue but none of these use npm. Does anyone has to deal with this issue ? Thank in advance

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It's a plugin code from datatables.net

You can download it from here: https://cdn.datatables.net/plug-ins/1.11.5/dataRender/datetime.js

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda