cancel
Showing results for 
Search instead for 
Did you mean: 

After rendering the page(sap.m.Page) in UI, focus always stays on first element of the page

0 Kudos

Hi Colleagues,

I have two pages called Page1 and Page2.

Page1 has "Submit" button.

After clicking of "Submit" button "Page2" will be getiing Rendered.

Page 2 has "Input" field.

After rendering of the "Page2" i wanna make focus on "Input" field but focus always stays on first element of the page that is "navButton".

Snippet Link: http://veui5infra.dhcp.wdf.sap.corp:8080/snippix/#6126

Please look into the snippet link and help me to change the focus on "Input Field"

Regards,

Suresh K

Accepted Solutions (0)

Answers (1)

Answers (1)

saivellanki
Active Contributor
0 Kudos

Hi Suresh,

At onAfterRendering event of your second page, try something like this:


var oInput = this.getView().byId("oInput");     //Get hold of the input that you want to focus on

jQuery.sap.delayedCall(0, null, function(){

     oInput.focus();

});

Not able to see your snippet, since I don't belong to SAP Network.

Regards,

Sai Vellanki.

0 Kudos

Hi Sai,

Whaterver you were proposed it's working properly.

But delayedCall is a kind of timer i dont want to beleive on timer logic to setFocus.

Because timer calls differs from each browser.

So do you have any idea of doing the same without timer logic?

saivellanki
Active Contributor
0 Kudos

Suresh,

You can remove the delayedCall code and try plain like this:


var oInput = this.getView().byId("oInput");

oInput.focus();

Also, if you see in the delayedCall code, the first argument which is time I mentioned as '0' which is zero seconds. (Which will not make any difference in different browsers).

Regards,

Sai Vellanki.