Hi Mike,
Please read this blog -> SAPUI5 Javascript and UniqueID definitions
And as for the solutions:
Kimmo's Solution
View code
var btn = new sap.m.Button(this.createId('myBtn'), { text: "Content Button" }); return new sap.m.Page({ title: "Title", content: [btn], press:[oController.onPress,oController] });
Controller code
onInit: function() { var that = this; window.setTimeout(function() { that.byId("myBtn").setVisible(true); }, Math.random() * 10000); }, onPress: function() { this.setText("I got pressed"); }
Another solution I could think of
View code
var btn = new sap.m.Button({ id: "myBtn", text: "Content Button" }); return new sap.m.Page({ title: "Title", content: [btn], press: [oController.onPress, oController] });
Controller code
onInit: function() { var that = this; window.setTimeout(function() { sap.ui.getCore().byId("myBtn").setVisible(true); }, Math.random() * 10000); }, onPress: function() { sap.ui.getCore().byId("myBtn").setText("I got pressed"); }
Both the above solutions could be understood by reading the blog.
Regards,
Naren L Naik