Just diving into the world of JavaScript, HTML, and web development tools here.
var labels = {{ labels|tojson|safe }};
After using console.log to check the content of labels with
console.log(JSON.stringify(labels));
, I got this output:
[
{"id":"1","image":"1-0.png","name":"","xMax":"4802","xMin":"4770","yMax":"156","yMin":"141"},
{"id":"2","image":"1-0.png","name":"","xMax":"4895","xMin":"4810","yMax":"157","yMin":"141"},
{"id":"3","image":"1-0.png","name":"","xMax":"4923","xMin":"4903","yMax":"156","yMin":"145"},
{"id":"4","image":"1-0.png","name":"","xMax":"4956","xMin":"4931","yMax":"156","yMin":"145"}
]
It seems like a list of dictionaries. Now my goal is to auto-update new elements without having to refresh the page manually. With some background in Python, I attempted to append by writing this line of code:
labels.append({"id":labels.length + 1,
"name":"",
"xMin":xMin,
"xMax":xMax,
"yMin":yMin,
"yMax":yMax
})
However, I'm encountering issues making it work. Any tips on how to successfully append that line?