Uncaught TypeError: Cannot read property 'replace' of undefined

Uncaught TypeError: Cannot read property 'replace' of undefined

radek_jvcradek_jvc Posts: 1Questions: 1Answers: 0
edited June 2014 in Free community support

Hello,

I have problem with error: Uncaught TypeError: Cannot read property 'replace' of undefined
- this exist on: http://localhost:53145/bundles/dataTables.editor.min.js

My table looks like:
`
<script type="text/javascript" language="javascript" class="init">

var editor; // use a global for the submit and return data rendering in the examples

$(document).ready(function () {
    editor = new $.fn.dataTable.Editor({
        ajax:
            {
            edit: {
                type: 'PUT',
                url: '/request/editplan.json'
            }
        },
        table: "#example",
        fields: [{
            label: "Model:",
            name: "productShortName"
        }, {
            label: "Lipiec:",
            name: "quantity1"
        }, {
            label: "Sierpień:",
            name: "quantity2"
        }, {
            label: "Wrzesień:",
            name: "quantity3"
        }, {
            label: "Październik:",
            name: "quantity4"
        }, {
            label: "Uwagi:",
            name: "description"
        }

        ]
    });

    $('#example').on('click', 'tbody td:not(:first-child)', function (e) {
        editor.inline(this);
    });

    $('#example').DataTable({
        dom: "Tfrtip",
        ajax: "/request/plan.json?id=@ViewBag.PlanId",
        columns: [
            { data: "id"},
            { data: "productShortName" },
            { data: "quantity1" },
            { data: "quantity2" },
            { data: "quantity3" },
            { data: "quantity4" },
            { data: "description" }
        ],
        tableTools: {
            sRowSelect: "os",
            aButtons: [
                { sExtends: "editor_edit", editor: editor }
            ]
        }
    });
});

</script>
`
can you help me with this?

Regards,
Radek

Answers

  • vmanvman Posts: 35Questions: 3Answers: 0

    Similar issue, has to do with the ajax request that is being made. Trying to figure it out.

  • celcatcelcat Posts: 2Questions: 0Answers: 0

    I had the same problem, editor doesn't seem to like having only the "edit" key set, it seems to expect the "create" key and falls over if it doesn't get it. As a temporary work around i've defined the key, but don't provide a button. I'll be looking into it a bit further when I get time but it looks like a genuine bug to me.

  • celcatcelcat Posts: 2Questions: 0Answers: 0
    edited November 2014

    The problem appears to be on line 3222 of dataTables.editor.js;

    opts = $.extend( {}, opts, ajaxSrc || {} );

    it looks like it fails to process the ajaxSrc object correctly when it only has one key. From debugging when the behaviour works as expected it looks like the "url" key of opts object should be set from the same key in ajaxSrc, but it's not in this case.

  • chopstikchopstik Posts: 14Questions: 5Answers: 0

    I'm seeing the same issue with the Editor plugin. I'm only setting an 'edit' and 'remove' url. I don't require the create method. If 'create' is not set dataTables.editor.js errors as celcat describes. The only way to avoid the error is to set the ajax create object which seems wierd.

  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin

    Hi,

    Thanks for flagging this up - sorry I didn't see this thread sooner.

    The issue is with this line:

    if ( $.isPlainObject( ajaxSrc ) && ajaxSrc.create ) {
    

    it should be:

    if ( $.isPlainObject( ajaxSrc ) && ajaxSrc[ action ] ) {
    

    That will be in the next beta.

    Regards,
    Allan

  • creatorDotJScreatorDotJS Posts: 20Questions: 6Answers: 0
    edited May 2015

    Was this fixed? I'm using Editor 1.4.2 Getting this error and I only have the edit button.

    Update:

    Got it to work.

  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin

    Yes, all 1.4.x final releases should have this fix in it. What did you do to get it to work in the end?

    Thanks,
    Allan

This discussion has been closed.