Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: Cannot read properties of undefined (reading 'dragTo') #174

Closed
Brecht272727 opened this issue Aug 26, 2022 · 1 comment

Comments

@Brecht272727
Copy link

Brecht272727 commented Aug 26, 2022

I am trying to make an ajax call with all boards and items inside. The data coming from the ajax is json and look like this:

[
    {
        "id": 1,
        "title": "New",
        "item": [
            {
                "id": 1,
                "title": "ID1
Second line<\/strong><\/div>
Thirth line
View<\/div><\/div>"
            },
            {
                "id": 2,
                "title": "ID2"
            },
            {
                "id": 3,
                "title": "ID3"
            }
        ]
    },
    {
        "id": 2,
        "title": "Working",
        "item": [
            {
                "id": 4,
                "title": "ID4"
            },
            {
                "id": 5,
                "title": "ID5"
            }
        ]
    },
    {
        "id": 3,
        "title": "Done",
        "item": [
            {
                "id": 6,
                "title": "ID6"
            }
        ]
    }
]

And the JS for init the kanban:

var kanban1 = new jKanban({
        element:'#demo1',  
        dropEl: function(el, target, source, sibling) {

          var _target = $(target.parentElement);
          var sorted = [];
          var nodes = kanban1.getBoardElements(_target.data("id"));
          var currentOrder = 0;
          nodes.forEach(function(value, index, array) {
            sorted.push({
              "id": $(value).data("eid"),
              "order": currentOrder++
            })
          });
          
          console.log(JSON.stringify(sorted));

          var sourceId = $(source).closest("div.kanban-board").attr("data-id"),
              targetId = $(target).closest("div.kanban-board").attr("data-id");

          console.log(sourceId)
          console.log(targetId)

          if(source === target) {
              // same column
          } else {
              // different column
          }
                
        },        
        boards  : boards
    });

But i got the error Uncaught TypeError: Cannot read properties of undefined (reading 'dragTo') in console?

@Brecht272727
Copy link
Author

I found out myself. It is because of the "id": 1. It has to be "id": "1" (See the double quotes around the numbers)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant