I’m trying to assign an object in the style of an associate array in JS but it’s failing, saying ‘task.id’ is undefined. Why is this?
var response = Object();
$('.task-list').each(function() {
response[this.id][$('#' + this.id).sortable('toArray')];
});
You are referencing the object as a two dimensional array.
You should do it more like this:
Also, when you say the error is “task.id is undefined”, do you mean “this.id is undefined”? If you are selecting elements based on class, they may not have an explicit id.
You may want to include an id: