sapui5 - Uncaught TypeError: Cannot read property 'setVisible' of undefined -
im new sapui5 , when click on button error in title did in used sap web ide create new mvc project .
in main view js set
createcontent : function(ocontroller) { var btn = new sap.m.button({ id:"mybtn", text : "content button" }); homecoming new sap.m.page({ title: "titlet", content: [ btn ] }); }
in main controller js set next code
oninit: function() { var = this; window.settimeout(function() { that.byid("mybtn").setvisible(true); }, math.random() * 10000); }, onpress: function() { this.byid("pressmebutton").settext("i got pressed"); }
when run see button when click on error in on init, doing wrong here?
the actual problem code create static id in javascript view, controller search id prefix "__jsview0--mybtn" if phone call that.byid("mybtn").
therefore either have utilize createid("mybtn") in javascript view defining id or sap.ui.getcore().byid("mybtn") in controller , work fine. first approach recommended though avoid name clashes.
ps: did not utilize case, seems want display button after (random) timeframe. visible flag default true, button visible.
sapui5 sapui
No comments:
Post a Comment