There is a button that triggers the parse method.
parse: function()
{
this.json.data = getDataFromAPI();
applyColor();
},
applyColor: function()
{
for (var i=0; i<this.json.data.length; i++)
{
var doc = document.getElementById(this.json.data[i].id);
doc.style.background = "red";
}
}
The issue here is that applyColor does not execute properly because this.json.data
is not available until the parse()
function finishes.
I would like to achieve a flow similar to:
this.json.data = getDataFromAPI();
exit parse() method
execute applyColor();
without making major changes to the code. Perhaps something along the lines of "set that aside for later" such as:
this.json.data = getDataFromAPI();
promise(500ms) applyColor();
exit parse() method
500ms
executes applyColor()
What I have attempted so far?
this.$forceUpdate(); before apply