I am making an app to track goals & the habits that those goals consist of.
I am however having trouble pushing the habits array to a specific goal.
I can declare the array of main goals & show the 'name' elements in html after getting the saved goals.
var _priValues = [{
name: "test1",
children:[]
}];
let storedValues = localStorage.getItem("_priValues", JSON.stringify(_priValues));
However, once I try to push a value to the children of the goal, as such:
_priValues[0].children.push("Work out every day");
Or like this:
_priValues.push({
[id] : {
name : "maingoal",
children : "subgoal"
}
});
The HTML will not show anymore and the array remains the same - no children are added to the main goal.
How I show the HTML (which is working fine as long as I dont push children):
for (var i = 0; i < _priValues.length; i++) {
var item = `
<h6>${_priValues[i].name}</h6>
<ul class="collectionDetails">
<li> ${_priValues[i].children} </li>
</ul>`;
$('.priorityList ul.collection').append(item);
};
Anyone have any idea as to why it's not working ?
I'm using Materialize for CSS & Cordova/phonegap to test it out, if that helps.