2013-06-04 14 views
10

入力ボックスにフォーカスを合わせ、pageshowでjquery mobileを使用してアンドロイドキーボードを表示しようとしています。入力ボックスにフォーカスを設定し、jquery mobileを使用してアンドロイドキーボードを表示しています。

私はウェブからたくさんのオプションを試しました。エミュレータとモバイルの両方で期待どおりに動作するものはありません。

<!DOCTYPE html> 
<html> 
    <head> 
     <title>Title</title> 
     <meta name="viewport" content="width=device-width, initial-scale=1"> 
     <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> 
     <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" /> 
    </head> 
    <body> 
     <div data-role="page" id="main"> 
      <div data-role="header"><h3>Set Focus, Show Keyboard</h3></div> 
      <div data-role="content"> 
       <label for="gotoPage"></label> 
       <input type="text" name="gotoPage" id="gotoPage" placeholder="Question No." data-mini="true" /> 
      </div> 
     </div>        

     <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script> 
     <script> 
      $(document).on('pageinit',"[data-role=page]", function() { 

      }); 

      $(document).on('pagebeforeshow',"[data-role=page]", function() {     

      }); 

      $(document).on('pageshow',"[data-role=page]", function() { 
       $('#gotoPage').focus().select();       
      }); 
     </script> 
     <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>  
    </body> 
</html> 

参照

enter image description here

enter image description here

親切にアドバイスをスクリーンショットを探す...事前のおかげで...

:ここ

はコードです

注:オマールあたりとして

それはIOSで正常に動作しているコメント.... 誰もが、我々は、これはアンドロイドで仕事を得る方法を提案することができますか?

+0

私は '必要とされている)('選ぶと思ういけない – krishgopinath

+0

'$(文書).on( 'pageshowの'、" [データ-役割=ページ] "、function(){$( '#gotoPage')。trigger( 'click')})' 'setTimeout'を使って遅延を設定する必要があるかもしれません。 – Omar

+0

正確なコードを入力してください... – Yesvinkumar

答えて

3

私の作品解決策:

$("#main").on("pageshow" , function() { 
$('#gotoPage').focus(); 
}); 
+1

このソリューションは、Android 4.0.4で動作しません。 –