2013-06-04 6 views
10

Sto provando a impostare lo stato attivo sulla casella di input e mostrando la tastiera Android utilizzando jquery mobile su pageshow.imposta lo stato attivo sulla casella di input e mostra la tastiera Android utilizzando jquery mobile su pageshow

Ho provato molte opzioni dal web. ma nessuno funziona come previsto sia nell'emulatore che nel cellulare.

Ecco il codice:

<!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> 

Trova le schermate per riferimento

enter image description here

enter image description here

consiglio gentile ... Grazie in anticipo ...

NOTA:

Come da Omar commenti si sta lavorando bene in ios .... qualcuno può suggerire come ottenere il lavoro presente in Android?

+0

Non penso il 'select()' è necessario – krishgopinath

+0

'$ (document) .on ('pageshow'," [data-role = page] ", function() {$ ('# gotoPage'). trigger ('click')});' potrebbe essere necessario impostare un ritardo usando 'setTimeout'. – Omar

+0

puoi fornire il codice esatto ... – Yesvinkumar

risposta

3

La soluzione che funziona per me:

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

Questa soluzione non funziona su Android 4.0.4. –