Hello Experts,
My requirement is to highlight textfield in focus with a particular color. I have a set of textfields being generated dynamically. I have used attachBrowserEvent("focus") for the same, but somehow it works only for the 1st time. The same textfield when focused again doesnt get highlighted thought the event does get called. Highlighted the relevant code
The code is as below:
for(var j=0;j<weekData.length;j++)
{
var weekNo = weekData[j].weekNo;
var oTimeProjCell = "ProjCell1"+weekData[j].weekNo+projNum+month+year;
var oTimeProjLayoutCell1 = new sap.ui.commons.layout.MatrixLayoutCell(oTimeProjCell,
{
backgroundDesign : sap.ui.commons.layout.BackgroundDesign.Transparent,
colSpan : 1,
hAlign : sap.ui.commons.layout.HAlign.Center,
padding : sap.ui.commons.layout.Padding.Both
});
var oTimeEntries = new sap.ui.commons.TextField("Week"+weekData[j].weekNo+'oTimeEntries'+projNum+'year'+year,{
width : '50px',
height: '90px',
}).attachBrowserEvent(
"focus",function(evt) {
console.log(sap.ui.getCore().getElementById(evt.target.id));
sap.ui.getCore().getElementById(evt.target.id).addStyleClass("timeEntryTextField");
console.log("Added");
}).attachBrowserEvent(
"blur",function(evt) {
sap.ui.getCore().getElementById(evt.target.id).addStyleClass("timeEntryBlur");
});