2012-11-12 57 views
0

我已經使用html5和jQuery,jQuery-mobile實現了登錄屏幕。無法在手機上使用jquery-mobile獲取屏幕

App.html

<!DOCTYPE html> 
<html> 
<head> 
<meta charset="ISO-8859-1"> 
<meta name="viewport" content="width=device-width, initial-scale=1"> 
<title>Application</title> 
<link rel="stylesheet" type="text/css" href="css/jquery.mobile-1.1.1.css" /> 
<!-- <link rel="stylesheet" type="text/css" href="css/jquery.mobile.structure-1.1.1.css" /> 
<link rel="stylesheet" type="text/css" href="css/jquery.mobile.theme-1.1.1.css" /> --> 
<link rel="stylesheet" type="text/css" href="css/login.css" /> 

<script type="text/javascript" src='js/jquery-1.8.2.js'></script>   
<script type="text/javascript" src="js/jquery.mobile-1.1.1.js"></script> 
<script type="text/javascript" src="js/login.js"></script> 
</head> 
<body> 
<div data-role="page" id="pagecontent" class="type-interior">  
</div> 
</body> 
</html> 

登錄.js文件

var _header = "<div data-role='header' data-theme='b' ><h1 id='pheader'>Mobile Sign On </h1> <a data-role='button' id='logoutbtn' data-theme='b' class='hide'>Logout</a></div>"; 
    var _content ="<div data-role='content'>" + 
      "<div align='center' id='logindiv'>"+ 
      "<div data-role='fieldcontain'><label for='userid' id='luserid'>User Name *:</label>"+ 
      "<input type='text' name='userid' id='userid' value='' class='logon required' placeholder='Username' /></div>"+ 
      "<div data-role='fieldcontain'><label for='password' id='lpassword'>Password *:</label><input type='password' name='password' id='password' class='logon required' value='' placeholder='Password' /></div>"+ 
      "<div data-role='fieldcontain'><fieldset class='ui-grid-a'><a data-role='button' id='loginbtn' data-theme='b'>Login</a></fieldset></div></div></div>"; 

要追加的標題和內容頁面。

$(document).ready(function(){ 
     $('#pagecontent').append(_header).trigger("pagecreate"); 
     $('#pagecontent').append(_content).trigger("pagecreate"); 
    } 

我能得到鉻登錄屏幕,但無法在手機上和Mozilla Firefox

能否請你幫我出這一點。

回答

0

Srikanth,document.ready()與JQM實現有點不同,也許這樣會做什麼?

$(document).bind('pageinit',function() 
{ 
    $.mobile.changePage("#pagecontent", { transition: "slide" }); 
    $('#pagecontent').live('pageshow', function (event, ui) { 
     $('#pagecontent').append(_header).trigger("pagecreate"); 
     $('#pagecontent').append(_content).trigger("pagecreate");  
    }); 
}); 
+0

感謝您的回覆。但沒有運氣。 –