简体   繁体   中英

Unable to get screen using jquery-mobile in mobile

I have implemented login screen using html5 and jQuery, 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>

login .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>";

To append the header and content to the page.

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

I am able to get the login screen in chrome but not on mobile and Mozilla firefox

Could you please help me out on this.

Srikanth, document.ready() is implemented a little differently with JQM, maybe something like this will do?

$(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");    
    });
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM