Getting undefined (reading 'attach') with multiple tables

Getting undefined (reading 'attach') with multiple tables

Matthew CzajkaMatthew Czajka Posts: 13Questions: 4Answers: 1

In my application I am trying to use multiple tables with multiple editors with in-line editing. When I go to click the edit button I get the console error "Cannot read properties of undefined (reading 'attach')". I get this error on all of my tables except the final table I have. I have designated different editors to the different tables, but the code only seems to be able to pick up the last table initialized. Attached is a sample of some of my code, unfortunately I do not have a link to my code. Any help/suggestion to have the Edit buttons picked up for each individual table would be helpful.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,144Questions: 26Answers: 4,736
    Answer ✓

    Looks like you are using the var table for each Datatable. You should use different variables for this like you have for the different Editors.

    That is why this click event:

        $('#otherDocsTable').on('click', 'tbody td.row-edit', function (e) {
            documentEditor.inline(table.cells(this.parentNode, '*').nodes(), {
                submitTrigger: -2,
                submitHtml: '<i class="fa fa-check"/>'
            });
        });
    

    and this click event:

        // Activate an inline edit on click of a table cell
        $('#notesTable').on('click', 'tbody td.row-edit', function (e) {
            notesEditor.inline(table.cells(this.parentNode, '*').nodes(), {
                submitTrigger: -2,
                submitHtml: '<i class="fa fa-check"/>'
            });
        });
    

    Only work on the last Datatable assigned to the variable table.

    Kevin

  • Matthew CzajkaMatthew Czajka Posts: 13Questions: 4Answers: 1

    That works. thank you! I didn't realize that even though I designate the id of the table to the click handler, that it's still picking up the variable table. I thought the "table" in the that statement was solely because it was a table.

Sign In or Register to comment.