on 12-09-2014 2:25 PM
Hi, what is the better way to access a View-Control from the Controller by its ID:
sap.ui.getCore().byId() or sap.ui.getCore().getElementById()?
Where is the difference?
Hi Michael,
I think its best to avoid calling the .byId() function via sap.ui.getCore() as much as possible and rather call it via the object its created under. such as oController.byId("idButton"); or this.byId("idButton") or oView.byId("idButton");
See this section on Unique Id's in UI5 Developers Guide:
SAPUI5 SDK - Developers Guide - Support for Unique ID's
Cheers,
Brad
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you're in the controller, you shouldn't use neither of them (for the most part).
Use byId of the controller. It will resolve the generated id prefixes automatically.
- Max
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes I know but
Maximilian Lenkeit sayed:
If you're in the controller, you shouldn't use neither of them (for the most part).
And I want to know what the alternative is if I should avoid this.
Both are the same & getElementByID() is deprecated. So, its better to use byId().
JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.ui.core.Core
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.