Uncaught TypeError: Math[(intermediate value)(...)] is not a function

Uncaught TypeError: Math[(intermediate value)(...)] is not a function

alexandresgfalexandresgf Posts: 1Questions: 1Answers: 0
edited July 2018 in Free community support

Hi guys,

I looked after the same error here, but didn't find anything related to this error. So, I'm using Django + Django Rest Framework + DataTables, and everytime I request the endpoint this error pops up:

Uncaught TypeError: Math[(intermediate value)(intermediate value)(intermediate value)] is not a function
     at datatables.js:46129
     at datatables.js:46129
     at datatables.js:46129
     at datatables.js:46129

This line has this code:

var remaining = Math[V2f.I2(T9r) ? e9V : V2f.Y5t]((new Date((V2f.u2(Z9V) ? n2t : J9V) * t2t)[f9r]() - new Date()[a9V]()) / (t2t * k2t * k2t * (V2f.W5(S9V) ? E2t : P2t)));

The error forces any button that I create, not to show. Also, I tested the endpoint and is everything fine.

Here is my code:

$(document).ready(function () {
        // Build the table
        $('table#roomsList').DataTable({
            dom: '<"wrapper" <"row" <"col custom-filter" B><"col" f>><"row" <"col" t>><"row mt-3" <"col" i><"col" p>>>',
            order: [[0, 'asc']],
            ajax: {
                url: '{% url "api:chat_rooms" %}',
                dataSrc: 'data'
            },
            language: {
                url: '//cdn.datatables.net/plug-ins/1.10.19/i18n/Portuguese-Brasil.json'
            },
            buttons: [
                {
                    text: 'Adicionar salas',
                    attr: {
                        id: 'btnAddSelectedRooms',
                        class: 'btn btn-light btn-sm'
                    },
                    action: function(e, dt, button, config) {
                        console.log('ok');
                    }
                }
            ],
            columns: [
                {
                    data: 'category',
                    render: function (data, type, row, meta) {
                        return data.replace(/-/g, ' ');
                    }
                },
                { data: 'group' },
                { data: 'name' },
                { data: 'online' }
            ],
            initComplete: function (settings, json) {
                $('div.custom-filter').append(`
                <div class="form-check form-check-inline">
                    <input class="form-check-input" type="checkbox" id="selectAllRooms" value="select_all_rooms">
                    <label class="form-check-label" for="selectAllRooms">Selecionar tudo</label>
                </div>
                <div class="form-check form-check-inline">
                    <input class="form-check-input" type="checkbox" id="filterFullRooms" value="remove_full_rooms">
                    <label class="form-check-label" for="filterFullRooms">Remover salas cheias</label>
                </div>
                <div class="form-check form-check-inline">
                    <input class="form-check-input" type="checkbox" id="filterEmptyRooms" value="remove_empty_rooms">
                    <label class="form-check-label" for="filterEmptyRooms">Remover salas vazias</label>
                </div>
                `);
            }
        });

        // Filter empty rooms
        $.fn.dataTable.ext.search.push(function (settings, data, dataIndex) {
            var online = data[3];

            if ($('input#filterEmptyRooms').is(':checked')) {
                if (online > {{ room_empty_val }}) {
                    return true;
                }

                var table = $('table#roomsList').DataTable();
                var row = table.row(dataIndex).node();

                if ($(row).hasClass('selected')) {
                    $(row).removeClass('selected');
                }

                return false;
            }

            return true;
        });

        // Filter full rooms
        $.fn.dataTable.ext.search.push(function (settings, data, dataIndex) {
            var online = data[3];

            if ($('input#filterFullRooms').is(':checked')) {
                if (online < {{ room_full_val }}) {
                    return true;
                }

                var table = $('table#roomsList').DataTable();
                var row = table.row(dataIndex).node();

                if ($(row).hasClass('selected')) {
                    $(row).removeClass('selected');
                }

                return false;
            }

            return true;
        });

        // Do filter rooms
        $('body').on('change', 'input#filterFullRooms, input#filterEmptyRooms', function () {
            var table = $('table#roomsList').DataTable();
            table.draw();
        });

        // Select all visible rooms
        $('body').on('change', 'input#selectAllRooms', function () {
            var table = $('table#roomsList').DataTable();

            if ($('input#selectAllRooms').is(':checked')) {
                table.rows('tr:not(".selected")', {search: 'applied'}).nodes().to$().toggleClass('selected');
            } else {
                table.rows('.selected').nodes().to$().removeClass('selected');
            }
        });

        // Select rooms one by one
        $('table#roomsList tbody').on('click', 'tr', function () {
            $(this).toggleClass('selected');
        });
    });

Any help, will be appreciated!

Thank you all, in advance!

Answers

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    The error message looks like it might have a trial version of Editor in it. Your initialisation code doesn't use Editor at all, so it might be worth rebuilding your download package without it (assuming that is the issue - if it isn't, I'd need a link to the page showing the issue).

    Allan

This discussion has been closed.