android - ReferenceError: Can't find variable: $, jquerymobile + phonegap -
i'm newbie. want save value inputted user in preferences manager, , have automatically populate field(if has been filled user). "referenceerror: can't find variable: $ @ file:///android_asset/www/index.html:53" in android logcat. app crashes. doing wrong?
<html> <head> <meta charset="utf-8" /> <meta name="format-detection" content="telephone=no" /> <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" /> <!--<link rel="stylesheet" type="text/css" href="css/index.css" />--> <link rel="stylesheet" type="text/css" href="css/jquery.mobile.structure-1.3.2.css" /> <link rel="stylesheet" type="text/css" href="css/jquery.mobile.theme-1.3.2.css" /> <link rel="stylesheet" type="text/css" href="css/jquery.mobile-1.3.2.css" /> <title>hello world</title> <script type="text/javascript"> document.addeventlistener("deviceready", ondeviceready, false); //once device ready event fires up, can safely thing function ondeviceready(){ //document.getelementbyid("welcomemsg").innerhtml += "phonegap ready! version="; } $(function(){ $('#savebutton').click(function(){ //this user manually keys in values, error checking here window.localstorage.setitem("user_lat", $('#user_lat').val()); }); //called when page being shown $('#newpage').live('pageshow', function(){ var userlat = window.localstorage.getitem("user_lat"); if (userlat.length > 0){ $('#user_lat').val(userlat); } }); }); </script> </head> <body> <div id="home" data-role="page"> <div data-role="header"> <h1>home page</h1> </div> <div data-role="content"> hola phonegap & jquery mobile! <a href="#newpage" data-role="button">go new page</a> </div> <div data-role="footer" data-position="fixed"> <h4>footer</h4> </div> </div> <!--2nd page--> <div id="newpage" data-role="page"> <div data-role="header"> <h1>manually specify gps coordinates</h1> </div> <div data-role="content"> <label for= "user_lat">latitude:</label> <input type="text" name="user_lat" id="user_lat" value=""/> <a id ="savebutton" href="" data-role="button">save</a> </div> <div data-role="footer" data-position="fixed"> <h4>footer</h4> </div> </div> <script type="text/javascript" src="phonegap.js"></script> <script type="text/javascript" src="js/jquery-1.10.1.js"></script> <script type="text/javascript" src="js/jquery.mobile-1.3.2.js"></script> </body>
if '$' isn't defined don't think jquery being loaded correctly..
try:
if ( $.mobile ) { // loaded } else { // not loaded }
to check if jquery mobile loaded, or try normal jquery:
if (!jquery) { alert("jquery not loaded"); }
Comments
Post a Comment