i Have created a site, wahts uses the HTML TEMPLATES. I can create the site and everything is showing correctly. But how can I update the values inside the template after creating?
HTML Part
...
<div class="row block-column align-items-center justify-content-center"></div>
<template id="DEVICE_TEMPLATE">
<div class="col-2 col-xl-2" align="center">
<a class="tDeviceHref " >
<img class="tDeviceImg" src="" height="50px" width="50px" title="">
</a>
</div>
<div class="col-10 col-xl-4 "">
<div class="devicePicture" align="center">
<a class="tDeviceLabel text-left" >Name</a>
</div>
<div class="progress" style="height: 25px;">
<div id="opwnwblp1" style="width: 100%;" class="bg-secondary progress-bar progress-bar-animated progress-bar-striped">
<div class="tDeviceVerbrauch "></div>
</div>
</div>
</div>
</template>
...
This ist the JS part:
function createGui(devices){
const templ = document.querySelector("#DEVICE_TEMPLATE")
for (var i = 0; i < allDeviceGroups.length; i++) {
// ...
const clone = templ.content.cloneNode(true);
clone.querySelector(".tDeviceImg").src = groupDevice["DEVICE"]["img"]["imgRunning"];
document.querySelector(".block-column").append(clone);
// ...
}
}
The above code is only a part of the hole one with more settings to the template, but not relevant for my question.
If i reload the function createGui, the the gui will append again and again aso. I like to refresh only the values of the parts, like chnage the img for
clone.querySelector(".tDeviceImg").src = groupDevice["DEVICE"]["img"]["imgRunning"];