in android, jquery mobile alert message not displaying

北战南征 提交于 2019-12-11 20:14:37

问题


i am executing below snippet in android mobile, i am able to see my web form, but jquery snippet not working.

public class MainActivity extends DroidGap {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.loadUrl("file:///android_asset/www/index.html");
    }

}

Jquery Snippet

   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/mobile/latest/jquery.mobile.css" />
<link type="text/css" href="http://dev.jtsage.com/cdn/datebox/latest/jqm-datebox.min.css" rel="stylesheet" />
<!-- NOTE: Script load order is significant! -->
<script type="text/javascript" src="http://dev.jtsage.com/cdn/datebox/latest/jqm-datebox.core.min.js"></script>
<script type="text/javascript" src="http://dev.jtsage.com/cdn/datebox/latest/jqm-datebox.mode.flipbox.min.js"></script>
<script type="text/javascript">
$(document).ready(function () // Call function when page is ready for load..
{
    alert("Step 1");
});
</script>
</head>
<body>
<div data-role="page">
  <div data-role="header"data-position="fixed" >
    <h1>My Income</h1>
  </div>
  <div data-role="content">
    <form id="myincome" data-ajax="true">
      <table data-role="table" data-mode="columntoggle">
        <tr>
          <th>CUSTOMER NAME</th>
          <th><input type="text" name="txt_cust_name" id ="txt_cust_name"/></th>
        </tr>
        <tr>
          <th colspan="2"><input type="button" value="Save Changes" id="save_me" /></th>
        </tr>
      </table>
    </form>
  </div>
  <div data-role="footer" data-position="fixed">
    <p>Footer</p>
  </div>
</div>
</body>
</html>

java script alert not displayed.


回答1:


use

    document.addEventListener("deviceready", onDeviceReady, false);
    function onDeviceReady() 
   {
    alert("Step 1");
    }

and read understand how pages are loaded in jquery mobile here is an example

http://jquerymobile.com/demos/1.2.0/docs/pages/page-template.html

right to view code or get the theory here

http://api.jquerymobile.com/loader/

all the best



来源:https://stackoverflow.com/questions/19907581/in-android-jquery-mobile-alert-message-not-displaying

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!