"cannot call method 'appendchild' of undefined" for some tile template RRS feed

  • Question

  • I'm creating a tile follow this

    var notifications = Windows.UI.Notifications;
    var template = notifications.TileTemplateType.tileWide310x150ImageAndText01;                      
    var tileXml = notifications.TileUpdateManager.getTemplateContent(template);
    var tileTextAttributes = tileXml.getElementsByTagName("text");   
    tileTextAttributes[0].appendChild(tileXml.createTextNode("Hello World! My very own tile notification"));
    var tileImageAttributes = tileXml.getElementsByTagName("image");
    tileImageAttributes[0].setAttribute("src", "ms-appx:///images/redWide.png");
    tileImageAttributes[0].setAttribute("alt", "red graphic");
    var squareTemplate = notifications.TileTemplateType.tileSquare150x150Text04;
    var squareTileXml = notifications.TileUpdateManager.getTemplateContent(squareTemplate);
    var squareTileTextAttributes = squareTileXml.getElementsByTagName("text");   
    squareTileTextAttributes[0].appendChild(squareTileXml.createTextNode("Hello World! My very own tile notification"));
    var node = tileXml.importNode(squareTileXml.getElementsByTagName("binding").item(0), true);
    var tileNotification = new notifications.TileNotification(tileXml);
    var currentTime = new Date();
    tileNotification.expirationTime = new Date(currentTime.getTime() + 600 * 1000);

    But i got this error message >>

    "0x800a138f - JavaScript runtime error: Unable to get property 'appendChild' of undefined or null reference"

    Then i change to use other tile template. It's work :(

    I try to change tileWide310x150ImageAndText01 to tileWideImageAndText01, but it still won't work.

    i have to use this tile template, what should i do ?

    is someone can help me ? thank you so much :)

    Wednesday, October 30, 2013 4:49 AM


  • Maybe you should check the element before calling appendChild

    if(el && el.appendChild){



    • Marked as answer by P'Tik Wednesday, October 30, 2013 9:40 AM
    Wednesday, October 30, 2013 8:03 AM