Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 3570

Re: Uncaught TypeError: Cannot read property 'setVisible' of undefined

$
0
0

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


Viewing all articles
Browse latest Browse all 3570

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>