javascripttvostvmltvjs

Updating the "Hero Image" in a TVOS template


I'm trying to dynamically update the hero image source, inside a TVOS productTemplate.

I'm able to do this for the description, for example:

function changeDescription(incomingString) {
    if (incomingString) {
        var theDescription = myDoc.getElementsByTagName("description").item(0);
        theDescription.innerHTML = incomingString;
    }
}

.. but it's not working for the src value for the hero image:

function changeHeroImage(incomingString) {
    console.log("local path: " + incomingString)
    if (incomingString) {
        var theHero = myDoc.getElementsByTagName("heroImg").item(0);
        var theHeroSrc = theHero.getAttribute("src");
        theHeroSrc.value = incomingString;
        // theHeroSrc.innerHTML = incomingString;
    }
}

I've verified the path is correct; what else should I look at?


Solution

  • try setAttribute

    theHero.setAttribute('src', incomingString)