So I've been encountering this error quite a bit lately and it looks like this...
Main.js:84 Uncaught TypeError: Cannot set property 'CurrParent' of undefined
And basically I have a couple draggable elements all of which have an attribute called "c_index" which is set to an integer, and what i'm doing with them is using them in another file which is going to act as some sort of a metadata file, and that's where the problem is: I'm storing the "c_index" of the element currently being dragged in a var called CI it looks like this:
var CI = event.relatedTarget.getAttribute("c_index");
and i'm using it like this:
Meta.elements.CI.CurrParent = 'workspace';
and the object that i'm trying to save into looks like this without editing:
var Meta = {
elements : {
}
}
Any help would be much appreciated :)
p.s: I'm using a framework called interact.js
Math.elements.CI
isundefined
.var CI = ...
code won't magically produce aCI
property onMeta.elements
. You'd wantMeta.elements.CI = event.relatedTarget.getAttribute("c_index");
. But note that that property will have a primitive string as a value. Setting a property on that primitive string later (Meta.elements.CI.CurrParent = ...
) is a long-winded no-op (it won't be kept). It would temporarily create a string object, set the property on the string object, and then throw the string object away, with no effect at all onMeta.elements.CI
.