Uncaught TypeError: $.fn.dataTable.Editor is not a constructor

Uncaught TypeError: $.fn.dataTable.Editor is not a constructor

aldikhanaldikhan Posts: 3Questions: 1Answers: 0
edited June 2016 in Free community support

Hi I am beginner programmer, I faced this error when I try to create datatable editor inline

$.fn.dataTable.Editor is not a constructor
What are the reason for that problem?

Here are my code :

                                var editor;
                var editor = new $.fn.dataTable.Editor( {} );
                
                new $.fn.dataTable.Editor( {
                    ajax:  'update-patient.php',
                    table: '#datatable-patient',
                    fields: [
                        { label: 'Phone', name: 'phone' },
                        { label: 'Name',  name: 'name'  },
                        { label: 'Birthdate', name: 'birthdate' },
                        { label: 'Joiningdate',  name: 'joiningdate'  },
                        { label: 'Gender', name: 'gender' }
                    ]
                } );
                
                $('#datatable-patient').on( 'click', 'tbody td:not(:first-child)', function (e) {
                    editor.inline( this, {
                        buttons: { label: '>', fn: function () { this.submit(); } }
                    } );
                } );
                
                $('#datatable-patient').DataTable( {
                    dom: "Bfrtip",
                    ajax: 'ajax-get-patient.php',
                    columns: [
                        {  "data": "phone" },
                        { "data": "name" },
                        { "data": "birthdate" },
                        { "data": "joiningdate" },
                        { "data": "gender" },
                    ],
                    select: true,
                    buttons: [
                        { extend: 'create', editor: editor },
                        { extend: 'edit',   editor: editor },
                        { extend: 'remove', editor: editor }
                    ]
                } );

Thanks

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • allanallan Posts: 63,799Questions: 1Answers: 10,514 Site admin

    It suggests that the dataTables.editor.js file hasn't been included on your page. Have you got a link to the page so I can take a look and debug it?

    Allan

  • aldikhanaldikhan Posts: 3Questions: 1Answers: 0

    I have put this script

    <script type="text/javascript" src="js/Editor-1.5.6/js/dataTables.editor.js"></script>
    

    but still show error "$.fn.dataTable.Editor is not a constructor".

  • allanallan Posts: 63,799Questions: 1Answers: 10,514 Site admin

    I'd really need a link to the page to understand what is going wrong I'm afraid. From your description it should be working okay, so I'm obviously missing some other information that I would need to be able to help resolve it.

    Allan

This discussion has been closed.