Uncaught TypeError: Cannot read property 'replace' of undefined

Uncaught TypeError: Cannot read property 'replace' of undefined

kmjnhbgvkmjnhbgv Posts: 2Questions: 1Answers: 0

Hi,

I would just like to ask for assistance regarding the issue that I am encountering in a datatable bubble editor program that I created in which I was presented with this error message : "Uncaught TypeError: Cannot read property 'replace' of undefined" in
dataTables.editor.min.js:378 . My program code is as follows:

var table = $('#SampleDatatable').DataTable({
"processing" : true,
"serverSide" : true,
"ajax" : {
"url": "sample/dataTable",
"data": function ( d ) {
console.log('dataCode - ' + dataCode);
d.mailCode = dataCode;
}
},
"rowCallback": function(row, data ) {
if ( $.inArray(data.DT_RowId, selected) !== -1 ) {
$(row).addClass(highlight);
}
},
"columnDefs": [
{ className: "centerclass", "targets": [ 0 ] },
{ "visible": true, "targets": 1, "width": "50%" },
{ "visible": true, "targets": 2 },
{ "visible": true, "targets": 3, "width": "15%", className: "centerclass" }
],
"columns": [
{ "data": "0" },
{ "data": "1" },
{ "data": "2" },
{ "data": "3" }
]
});

    var editor = new $.fn.dataTable.Editor( {
        "table" : "#SampleDatatable",
        fields: [ {
                label: "Name",
                name: "0"
            }, {
                label: "Age",
                name: "1"
            }, {
                label: "Address",
                name: "2"
            }, {
                label: "Number",
                name: "3"
            }
        ],
        "formOptions" : {
            bubble: {
                title: 'Edit',
                buttons: false
            }
        }
    } ); 

        $('button.new').on( 'click', function () {
            editor
                .title( 'Create new row' )
                .buttons( { "label": "Add", "fn": function () { editor.submit() } } )
                .create();
        } );

    $('#SampleDatatable tbody').on( 'dblclick', 'td', function (event) {
        if ( $(this).index() < 4 ) {
            editor.bubble( this );
        }

});

    $('#SampleDatatable').on( 'click', 'a.remove', function (e) {
        editor
            .title( 'Delete row' )
            .message( 'Are you sure you wish to delete this row?' )
            .buttons( { "label": "Delete", "fn": function () { editor.submit() } } )
            .remove( $(this).closest('tr') );
    } );

My file loading order is as follows:

jquery.fileupload.js
jquery.iframe-transport.js
jquery.ui.widget.js
jquery.fileupload.css
jquery.dataTables.min.css
jquery.dataTables.min.js
dataTables.editor.js
dataTables.editor.min.js
editor.dataTables.css
editor.dataTables.min.css

Your assistance regarding this matter would be greatly appreciated, thanks!

Answers

  • allanallan Posts: 63,274Questions: 1Answers: 10,424 Site admin

    Could you give me a link to the page showing the issue so I can help to debug it please.

    Thanks,
    Allan

  • kmjnhbgvkmjnhbgv Posts: 2Questions: 1Answers: 0

    Hi allan,

    Thanks for your immediate response, My application is only residing on my local machine and the codes are indicated in my earlier post. I am using the chrome dev tool so as to why I was able to indicate the issue that I am encountering. This happens whenever I try to modifiy a field value in a bubble editor and press enter that the error message appears.

  • allanallan Posts: 63,274Questions: 1Answers: 10,424 Site admin

    Does the Ajax request get sent to the server? What is the response from the server if it does?

    It would be really helpful if you were able to put it up on the web somewhere. I don't see the issue from the code above I'm afraid and would need to be able to debug it.

    Allan

This discussion has been closed.