Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Dynamically Added JET Components Not Rendering

ZacDJan 3 2018 — edited Jan 3 2018

Hello,

In JET 4.0.0 I have an oj-input-text that is rendered inside of a div.

<div id="dynContainer">

\<oj-label>Value:\</oj-label>

\<oj-input-text value="{{inputValue}}" id="dynInput">\</oj-input-text>

</div>

pastedImage_1.png

pastedImage_14.png

Now, say I want to make it so that the element is programmatically added to the DOM instead of coded into the HTML file at design time. I found this Stackoverflow answer about programmatically adding elements based on HTML strings that I thought may be relevant since JET components are HTML custom elements now in JET 4+. However, when I tried implementing it, the oj-input-text is not rendering.

<div id="dynContainer">

\<oj-label>Value:\</oj-label>

</div>

    self.inputValue = ko.observable('test');

    $(document).ready(function () {

        var template = document.createElement('template');

        template.innerHTML = '\<oj-input-text value="{{inputValue}}" id="dynInput">\</oj-input-text>';

        $('#dynContainer').append(template.content.firstChild);

    });

pastedImage_16.png

The generated HTML does show that an oj-input-text tag was added to the DOM:

pastedImage_12.png

But it looks like whatever rendering process actually builds out the contents of the oj-* components is not getting run. So I guess the question is this: is dynamically adding JET components like this even possible currently and if so, what am I doing wrong?

This post has been answered by ZacD on Jan 3 2018
Jump to Answer
Comments
Post Details
Added on Jan 3 2018
2 comments
1,092 views