Editor is not defined && define is not defined.

Editor is not defined && define is not defined.

esmurfesmurf Posts: 29Questions: 4Answers: 0

Hi y'all,

I've got this error with Editor.. Uncaught ReferenceError: editor is not defined ...
I get it with the code below, but it works fine except that search and paging isn't working. It loads the first page and not much more..
My editor in the code below is called "editorUVID2", and if I change it to "editor", then the error is gone and search and paging works?

The other error, Uncaught ReferenceError: define is not defined, is referring to dataTables.editor.min.js:1, and nothing else. How to fix that?

Ty in advance :smile:

<body class="dt-example">
<div class="container"  style="float: left">
    <section>
        <h1>UVID</h1>
        <div id ="uvidFormTable">
            <fieldset class="ENGSNIPUVID">
                <legend>Engelsk</legend>
                <editor-field name="scan_vendor"></editor-field>
                <editor-field name="vendor_id"></editor-field>
                <!--                <editor-field name="identifier_id"></editor-field>-->
                <editor-field name="vuln_title"></editor-field>
                <editor-field name="type"></editor-field>
                <editor-field name="area"></editor-field>
                <editor-field name="base_cvss"></editor-field>
                <editor-field name="severity"></editor-field>
                <editor-field name="vuln_descr"></editor-field>
                <editor-field name="vuln_conseq"></editor-field>
                <editor-field name="vuln_solution"></editor-field>
            </fieldset>
            <fieldset class="DKSNIPUVID">
                <legend>Dansk</legend>
                <editor-field name="snip_lang_title"></editor-field>
                <editor-field name="lang_description"></editor-field>
                <editor-field name="snip_lang_recom"></editor-field>
                <editor-field name="notes"></editor-field>
            </fieldset>
        </div>
        <table id="uvidOverviewTable" class="display" style="float: left">
            <thead>
            <tr>
                <th>scan vendor</th>
                <th>vendor</th>
                <th>vuln title</th>
                <th>type</th>
                <th>area</th>
                <th>base_cvss</th>
                <th>severity</th>
                <th>vuln descr</th>
                <th>vuln conseq</th>
                <th>solution</th>
                <th>language </th>
                <th>title</th>
                <th>recom</th>
                <th>description</th>
                <th>notes</th>
            </tr>
            </thead>
        </table>
    </section>
</div>
</body>
<script>

    let editorUVID2; // use a global for the submit and return data rendering in the examples

    $(document).ready(function() {
        editorUVID2 = new $.fn.DataTable.Editor( {
            ajax: {
                create: {
                    type: 'POST',
                    url: '../backend/backendCRUD/uvidCRUD/create.php'
                },
                edit: {
                    type: 'POST',
                    url: '../backend/backendCRUD/uvidCRUD/edit.php?id=_id_'
                },
                remove: {
                    type: 'POST',
                    url: '../backend/backendCRUD/uvidCRUD/remove.php?id=_id_'
                }
            },
            table: "#uvidOverviewTable",
            template: "#uvidFormTable",
            fields: [
                {
                    label: "Scan vendor",
                    name: "scan_vendor",
                },
                {
                    label: "vendor id",
                    name: "vendor_id"
                },
                {
                    label: "Title",
                    name: "vuln_title"
                },
                {
                    label: "Type",
                    name: "type"
                },

                {
                    label: "Area",
                    name: "area"
                },
                {
                    label: "Cvss",
                    name: "base_cvss"
                },
                {
                    label: "Severity",
                    name: "severity"
                },
                {
                    type : "textarea",
                    label: "Description",
                    name: "vuln_descr"
                },
                {
                    type: "textarea",
                    label: "Consequence",
                    name: "vuln_conseq"
                },
                {
                    type: "textarea",
                    label: "Solution",
                    name: "vuln_solution"
                },
                {
                    label: "language",
                    name: "snip_language"
                },
                {
                    label: "Title",
                    name: "snip_lang_title"
                },
                {
                    type: "textarea",
                    label: "Solution",
                    name: "snip_lang_recom"
                },
                {
                    type: "textarea",
                    label: "Description",
                    name: "lang_description"
                },
                {
                    type: "textarea",
                    label: "Notes",
                    name: "notes"
                }
            ]
        } );

        $('#uvidOverviewTable').DataTable( {
            dom: "Blfrtip",
            ajax: {
                url: "../backend/getUvidBack.php",
                type: 'POST'
            },
            processing: true,
            serverSide: true,
            responsive: true,
            columns: [
                {
                    data: "scan_vendor"
                },
                {
                    data: "vendor_id"
                },
                {
                    data: "vuln_title"
                },
                {
                    data: "type"
                },
                {
                    data: "area"
                },
                {
                    data: "base_cvss"
                },
                {
                    data: "severity"
                },
                {
                    data: "vuln_descr",
                    render: function ( data, type, row ) {
                        if (data != null){
                            return data.length > 10 ?
                                data.substr( 0, 10 ) +'…' :
                                data;
                        }
                    },
                },
                {
                    data: "vuln_conseq",
                    render: function ( data, type, row ) {
                        if (data != null){
                            return data.length > 10 ?
                                data.substr( 0, 10 ) +'…' :
                                data;
                        }
                    },
                },
                {
                    data: "vuln_solution",
                    render: function ( data, type, row ) {
                        if (data != null){
                            return data.length > 10 ?
                                data.substr( 0, 10 ) +'…' :
                                data;
                        }
                    },
                },
                {
                    data: "snip_language"
                },
                {
                    data: "snip_lang_title"
                },
                {
                    data: "snip_lang_recom",
                    render: function ( data, type, row ) {
                        if (data != null){
                            return data.length > 10 ?
                                data.substr( 0, 10 ) +'…' :
                                data;
                        }
                    },
                },
                {
                    data: "lang_description",
                    render: function ( data, type, row ) {
                        if (data != null){
                            return data.length > 10 ?
                                data.substr( 0, 10 ) +'…' :
                                data;
                        }
                    },
                },
                {
                    data: "notes",
                    render: function ( data, type, row ) {
                        if (data != null){
                            return data.length > 10 ?
                                data.substr( 0, 10 ) +'…' :
                                data;
                        }
                        return data;
                    },
                },

            ],
            select: true,
            buttons: [
                { extend: "create", editor: editorUVID2 },
                { extend: "edit",   editor: editorUVID2 },
                { extend: "remove",   editor: editorUVID2 },
            ]
        } );

    } );

</script>

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @esmurf ,

    You would normally get those errors if you aren't including the correct sources. If you look at this example here, ensure you have the necessary files listed on the Javascript and CSS tabs beneath the table. Are you using a trial version of Editor, or licensed?

    Cheers,

    Colin

  • esmurfesmurf Posts: 29Questions: 4Answers: 0

    hi @colin
    Ty for reply.

    It's licensed, and I've just checked for the necessary files and I got all of them. You can see my JS and CSS below. I'm using Editor-php-1.7.4.

    I've changed computer several times and copied my project over for further development. Could that have effected it somehow?

    Kind regards,
    Esmurf.

    <html xmlns="http://www.w3.org/1999/html">
    
    <head>
        <title>ReGen 2.0</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="description" content="ReGen Alpha">
        <meta name="author" content="Shiva">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
        <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.17/css/jquery.dataTables.min.css">
        <link rel="stylesheet" type="text/css" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
        <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.5.2/css/buttons.dataTables.min.css">
        <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/select/1.2.6/css/select.dataTables.min.css">
        <link rel="stylesheet" type="text/css" href="../Editor-PHP-1.7.4/css/editor.dataTables.min.css">
    
    <link rel="stylesheet" type="text/css" href="https://editor.datatables.net/extensions/Editor/css/editor.dataTables.min.css">
    
    
        <link rel="stylesheet" type="text/css" href="../Editor-PHP-1.7.4/examples/resources/syntax/shCore.css">
        <link rel="stylesheet" type="text/css" href="../Editor-PHP-1.7.4/examples/resources/demo.css">
        <link href="https://nightly.datatables.net/css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
    
        <!--        <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap.min.css">-->
        <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
        <link rel="icon" href="../images/favicon.ico" type="image/x-icon" />
        <link href="https://fonts.googleapis.com/css?family=Arimo" rel="stylesheet">
    
        <!-- Nedenstående er for PHPWORD...-->
        <link rel="stylesheet" href="../PHPWord/samples/bootstrap/css/phpword.css" />
        <link rel="stylesheet" href="../PHPWord/samples/bootstrap/css/bootstrap.min.css" />
        <link rel="stylesheet" href="../PHPWord/samples/bootstrap/css/font-awesome.min.css" />
    
    
        <!-- Nedenstående er for DataTables...-->
        <script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.js"></script>
        <script type="text/javascript" src="https://nightly.datatables.net/js/jquery.dataTables.js"></script>
        <script type="text/javascript" src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
        <script type="text/javascript"  src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
        <script type="text/javascript"  src="https://cdn.datatables.net/buttons/1.5.4/js/dataTables.buttons.min.js"></script>
    <!--    <script type="text/javascript" language="javascript"  src="https://cdn.datatables.net/buttons/1.2.2/js/buttons.print.min.js"></script>-->
        <script type="text/javascript"  src="https://cdn.datatables.net/select/1.2.7/js/dataTables.select.min.js"></script>
        <script type="text/javascript" src="../Editor-PHP-1.7.4/js/dataTables.editor.min.js"></script>
        <script type="text/javascript" src="../Editor-PHP-1.7.4/examples/resources/syntax/shCore.js"></script>
        <script type="text/javascript"  src="../Editor-PHP-1.7.4/examples/resources/demo.js"></script>
        <script type="text/javascript"  src="../Editor-PHP-1.7.4/examples/resources/editor-demo.js"></script>
        <script type="text/javascript"  src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        <script type="text/javascript"  src="https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap.min.js"></script>
        <script type="text/javascript"  src="https://editor.datatables.net/extensions/Editor/js/dataTables.editor.min.js"></script>
        <!-- Busy Load JS -->
        <script src="https://cdn.jsdelivr.net/npm/busy-load/dist/app.min.js"></script>
    
        <!-- Busy Load CSS -->
        <link href="https://cdn.jsdelivr.net/npm/busy-load/dist/app.min.css" rel="stylesheet">
        <script type="text/javascript"  src="https://cdn.datatables.net/plug-ins/1.10.13/api/fnDisplayRow.js"></script>
    
    </head>
    
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Remove these two lines:

        <script type="text/javascript"  src="../Editor-PHP-1.7.4/examples/resources/demo.js"></script>
        <script type="text/javascript"  src="../Editor-PHP-1.7.4/examples/resources/editor-demo.js"></script>
    

    They are specific to our demos and assume certain things about the source (e.g. that there is a variable called editor).

    Allan

This discussion has been closed.