我有一个UIComponent与此视图:
<mvc:View controllerName="my.components.webmap.controller.Map"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m"
xmlns:html="http://www.w3.org/1999/xhtml">
<html:div id='myDiv' style='height:inherit'></html:div>
<Button id="helloWorld" text="Say Hello" press=".onShowHello" />
</mvc:View>
在View控制器中,我可以从中获取Button及其ID
this.getView().byId("helloWorld").sId
但我无法使用该byId()
方法获取div的ID 。
this.getView().byId("myDiv"); // returns undefined
如何获取div的ID以访问元素?我需要div的ID,以便可以向其添加一些其他的第三方控件。
您可以使用createId
将您的lokal ID转换为全局ID,然后将其用于getElementById
:
// After rendering
var divId = this.createId("myDiv"); // this == controller instance
document.getElementById(divId).whatEver