cancel
Showing results for 
Search instead for 
Did you mean: 

core:HTML element is not accessible in Eclipse

0 Kudos

In VSCode the code works fine: in the view I have

<core:HTML content='<div id="chart"></div>'></core:HTML>

where content is written as suggested by https://sapui5.hana.ondemand.com/#/sample/sap.ui.core.sample.Html/code

In corresponding controller I have

onInit: function() {
        var oThis = this;
        $(oThis.initializeViz);
},
initializeViz: function () {
        var oThis = this;      
        oThis.oAnchor = document.getElementById("chart");
        var url = "whatever url";
       };
   oThis.viz = new tableau.Viz(oThis.oAnchor, url);
}

The problem is that document.getElementById("chart") returns null. However, in VSCode it works fine. Just wondering if i am missing something here or its an Eclipse issue? Thanks for help!

Accepted Solutions (1)

Accepted Solutions (1)

junwu
Active Contributor

try in onafterrendering

0 Kudos

Actually, it was easy. You are right, I just needed to call initializeViz function from onAfterRendering when the view has been rendered and HTML functionality is supported. Thanks!

Who knows why it worked from onInit in VSCode...(a rhetorical question)

Answers (2)

Answers (2)

0 Kudos

Yes, I forgot to remove }; when copy-pasting parts of my code.

I try to get the div element with id="chart" by doing this: document.getElementById("chart");

And this div element should be accessible because I added a corresponding control to my view: <core:HTML>

BTW, the content property of <core:HTML> has been changed from right syntax (as defined in SAPUI5 SDK Demo) to what you see above when I submitted the question.

Thanks!

ericci
Active Contributor
0 Kudos

Hi Sergey Kochetkov, what would you like to do?

You code has a lot of syntax error as far as I can see. If you explain us what you want to accomplice we can give you help.