var oButton1 = new sap.ui.commons.Button({
text:"Button" });
oButton1.placeAt("content");
jQuery.sap.delayedCall(2000, oButton1, "setText", ["Jerry"]);
In the production code it definitely does not make sense to use this hard code delay. Again I prepare a most simple application for our goal of this blog: research button control and its underlying DOM.
The simple application has the following structure:
-- buttontutorial
|- view
|- simple.controller.js
|- simple.view.xml
-- index.html
content of simple.controller.js:
sap.ui.controller("buttontutorial.view.simple", {
onInit : function() {
var oButton = this.getButtonReference();
var oDom = oButton.getDomRef();
debugger;
},
onBeforeRendering: function() {
var oButton = this.getButtonReference();
var oDom = oButton.getDomRef();
debugger;
},
onAfterRendering: function() {
var oButton = this.getButtonReference();
var oDom = oButton.getDomRef();
debugger;
},
getButtonReference: function() {
return this.getView().byId("jerryButton");
}
});
content of simple.view.xml:
<core:View xmlns:core="sap.ui.core" xmlns:common="sap.ui.commons" controllerName="buttontutorial.view.simple">
<common:Button text="Jerry" id="jerryButton"/>
</core:View>
content of index.html:
My favorite way to explore how to make use of some API is to check how UI5 framework does. Search via keyword "getDomRef" and just check the hit from another control, sap.m.Button.
Change source code of onAfterRendering() function as below:
onAfterRendering: function() {
var oButton = this.getButtonReference();
var oDom = oButton.getDomRef();
jQuery.sap.require("sap.ui.core.theming.Parameters");
oDom.style.color = sap.ui.core.theming.Parameters.get("sapUiAccent2");
oDom.style.backgroundColor = sap.ui.core.theming.Parameters.get("sapUiErrorBG");
debugger;
},
The detail color of sapUiAccent2 and sapUiErrorBG could be found here
Final result:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
28 | |
24 | |
19 | |
13 | |
12 | |
11 | |
10 | |
8 | |
7 | |
6 |