Skip to content
This repository was archived by the owner on Sep 21, 2022. It is now read-only.
This repository was archived by the owner on Sep 21, 2022. It is now read-only.

Adding templates dinamycally #21

@roalva1

Description

@roalva1

Hello,

I was wondering if we can add templates dynamically, i.e. to create a select with values , put it in a template and add it to the sortable table. This is my code:

cellTemplate = "newCellTemplate";
var el = document.createElement("template");
el.id = cellTemplate;
var td = document.createElement("td");
el.appendChild(td);
var select = document.createElement("select");
select.setAttribute("type", "text");
td.appendChild(select);
for (var i = 0; i < this.categoricalValues.length; i++) {
var option = document.createElement("option");
option.value = this.categoricalValues[i];
var text = document.createTextNode(this.categoricalValues[i]);
option.appendChild(text);
select.appendChild(option);
}
this.$.sortable_table.shadowRoot.appendChild(el);
//this.$.sortable_table.appendChild(el);

The html element is well created and you can see the element in DOM, but it does not appear what was expected. If I put the template directly, not programatically in the code it works good, so it is not the way the template is created:

Regards, thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions