Skip to Content
avatar image
Former Member

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

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Apr 01, 2016 at 06:14 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

    • 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.