locked
Search box autofocus in winjs RRS feed

  • Question

  • I need to autofocus the search box in windows phone 8.1 mobile application. When user clicks the search icon in app bar, new page will be opened and it has only one input element which is search box. When this page gets ready the search box would be focused automatically. This is my scenario, I have tried the following ways which is not worked,

    1. using 'autofocus' property in input element // not working

    2. On page ready, var element = document.getElementById("searchValue"); element.focus(); // not working

    3. $("#searchValue").focus() // not working

    4. No-2 & 3 were working if i done it on button click, but not working on page ready. Also tried timer event to trigger the button click, but that also not working.

    Any suggestion/help would be appreciated.

    • Moved by Jamles Hez Saturday, February 28, 2015 2:14 PM
    Monday, February 23, 2015 10:11 AM

All replies

  • Hi User2289,

    That means your searchbox is named searchValue and it is a input type=text control?

    As we can see from the emulator, the textbox is indeed get focused with blue border, but without cursor inside.

    I will further consult to see if we can have a quick walkaround for this scenario. Will reply once I have some update.

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, February 24, 2015 3:20 AM
  • Hi Jamles Hez,
      Thanks for your response, this is what exactly i want. And i am eagerly waiting for your further response.

    Tuesday, February 24, 2015 6:30 AM
  • Hi User2289,

    Thanks for your understanding and I just got reply from product team, this behavior is by design with reasons:

    The main reason for not automatically showing the keyboard in response to a script focus() is that it’s not always a strong indicator that a touch keyboard should be shown. To prevent overly-aggressive keyboard invocation of script invocations, we require the focus to be initiated by user interaction as you observed.

    If you have suggestion for this feedback, please submit your suggestion on https://wpdev.uservoice.com/forums/110705-dev-platform with reasons :)

    As a suggestion you may let user touch the input textbox to show soft keyboard, for instance set a watermark text on the textbox.

    --James 


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Saturday, February 28, 2015 2:08 PM
  • Hi James,

          Thanks for your response, that's okay. But the same thing (overly-aggressive keyboard invocation of script invocations) will be happen for windows serachbox also right? i wonder why you have given support only for windows application and not for windows mobile application. Can you please brief about this?

    Monday, March 2, 2015 9:33 AM
  • Hi User2289,

    To be clear, 1, SearchBox object is not simply a input control, it has code behind to support its functionalities. 2, SearchBox does not work on Windows Phone, if we need autofocus it, we have focusOnKeyboardInput propriety.

    I don't know why it is not available for Windows Phone at this moment, I hope it can be available but I cannot comment for feature. If you would like to have this feature in Windows Phone, please raise your idea at our feedback channel: https://wpdev.uservoice.com/forums/110705-dev-platform

    Thanks for your understanding.

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Saturday, March 7, 2015 4:14 PM
  • Hi James,

    Thanks for your patience to reply my queries. I will check about this.

    Monday, March 16, 2015 6:25 AM