2017-10-16 84 views
0

只要我的页面加载,我的重点是用户输入第一个数字到otp。当我这样做的jQuery,默认情况下,数字键盘不visible.later我手动如果我的重点,我得到的数字键盘。如何解决这个问题?jquery聚焦到数字输入不会触发手机的数字键盘

这里是我的代码:

setTimeout(function(){ 
       Ember.$('.digit0').focus(); 
      }, 100); 

我的html:

{{#each cardDigitField as |field index| }} 
       <input type="number" tabindex="{{count}}" min="0" max="9" maxlength="1" value='' 
        pattern="[0-9]*" inputmode="numeric" 
        onKeyUp={{action "numberEntered" index }} 
        onKeyPress={{action "numberInit" }} 
        onPaste={{action "numberPaste" }} class="digit{{index}}" > 
        {{#if requiredHyphen}} 
         {{add-hyphen index 4 cardDigitField.length}} 
        {{/if}} 
      {{/each}} 
+0

您是否尝试使用['input'](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input)的'autofocus'属性? – ykaragol

回答

1

一般setTimeout和Ember的runloop不玩在一起很好。如果你在你的组件中使用afterRender钩子,那么你的jQuery有更好的成功吗?