在winjs中搜索框自动对焦 [英] Search box autofocus in winjs

查看:60
本文介绍了在winjs中搜索框自动对焦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我需要在windows phone 8.1移动应用程序中自动对焦搜索框。当用户单击应用栏中的搜索图标时,将打开新页面,并且它只有一个输入元素,即搜索框。当此页面准备就绪时,搜索框将自动聚焦
。这是我的情况,我尝试了以下不起作用的方法,



  1. 在输入元素中使用'autofocus'属性//无法正常工作



  2. 在页面就绪,var element = document.getElementById(" searchValue"); element.focus(); //不工作



  3. < p style ="padding-right:0px; clear:both"> $(&#"searchValue")。focus()// not working



  4. No-2& 3如果我按下按钮点击它,但在页面准备就绪时没有工作。还尝试了计时器事件来触发按钮点击,但这也无效。




任何建议/帮助将不胜感激。

解决方案

您好User2289,


这意味着您的搜索框名为searchValue并且是输入type = text control?


我们可以从模拟器中看到,文本框的确是聚焦蓝色边框,但没有光标。



我会进一步咨询,看看我们是否可以拥有快速浏览此方案。一旦我有更新,我们会回复。


- 詹姆斯




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.

解决方案

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


这篇关于在winjs中搜索框自动对焦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆