Editor not working on first column

Editor not working on first column

IsaacBenIsaacBen Posts: 35Questions: 8Answers: 4

I'm using the same configuration that I use for another table that works just fine, but on this specific table the first column doesn't seem to be editable. Only the second column is editable.

    var editor = new $.fn.dataTable.Editor( {
        ajax: {
            edit: {
                type: 'PUT',
                url:  '/statuses/22',
                dataType: 'JSON',
                beforeSend: function (xhr) {
                    var token = $('meta[name="csrf_token"]').attr('content');
                    if (token) {
                        return xhr.setRequestHeader('X-CSRF-TOKEN', token);
                    }
                },
            },
            remove: {
                type: 'DELETE',
                url:  '/client'
            }
        },
        table: 'table.status-table',
        idSrc:  'id',
        fields: [
            { label: 'Status', name: 'name' },
            { label: 'Count', name: 'tickets_count' },
        ]
    });

    editor.on('submitSuccess', function (e, json, data) {
        toastr.success("Status has been updated successfully!");
    });

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


    var table = $('table.status-table').DataTable({
        select: true,
        lengthChange: true,
        ajax: '/statuses',
        columns: [
            { "data": "name" },
            { "data": "tickets_count" },
        ],
    });

The code for both tables never exists together so collision is not an option. The only thing I can think of is that I'm not allowed to use the word "name" as a name field.

I get no errors, it's simply doesn't respond. Any ideas?

This question has an accepted answers - jump to answer

Answers

  • IsaacBenIsaacBen Posts: 35Questions: 8Answers: 4
    Answer ✓

    Well, this is what happens when I just copy code from this site without looking carefully. I had to remove this part from the click handler - :not(:first-child).

  • allanallan Posts: 63,831Questions: 1Answers: 10,518 Site admin

    Thanks for posting back - that looks exactly right!

    Allan

This discussion has been closed.