I am using phonegap to build parse cloud..First i tried to build code with my browser and checked in that it works without any errror. But when i copied to eclipse (phonegap) ,
Parse.Initialize line is getting error:
Error:
Uncaught ReferenceError: Parse is not defined at file:///android_asset/www/index.html:36
MYCODE:
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/parse-1.2.18.min.js"></script>
<script type="text/javascript">
$(document).on('pageshow', '#index', function(){
Parse.initialize("HxxxxxxxxxxxxxmALn","x5qxxxxxxxxxxxxxxxxxxxxxVk"); });
</script>
Related
I am trying to build a simple cordova app on iOS and Android. It worked fine on iOS. However it fails to execute on android. I am using Android Studio.
The html file still runs in android, but the addEventListener for deviceReady is not working.
This piece of code works fine in iOS but not in android:
<p id="ready" style="text-align: center">deviceready not called yet</p>
<script type="text/javascript" src="cordova-2.4.0.js"></script>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript">
document.addEventListener("deviceready", function() {
console.log("cordova ready");
var readyElement = document.getElementById("ready");
readyElement.innerHTML = "deviceready called but not finished";
readyElement.innerHTML = "Ready";
console.log('Ready');
}, false);
</script>
I have included the both cordova-2.4.0.js and cordova.js in the project folder, but I have no idea why it doesnt connect properly.
After the page loads, the label 'device ready not called yet should be changed to device ready' , but it doesnt change in android. Can anyone suggest me the right way to do it ?
Note: 'cordova.js' is generated by the cordova in android , and 'cordova-2.4.0.js' is the one generated in iOS.
Even though I copied the iOS cordova-2.4.0.js file, it didnt worked.
Looks like I have to include only one cordova.js file generated by the cordova .
I removed the line:
<script type="text/javascript" src="cordova-2.4.0.js"></script>
and I used only:
<script type="text/javascript" src="cordova.js"></script>
and it worked.
I don't know why the plugin manager throw exec() call to unknown plugin: StatusBarNotification, I downloaded a example and tried to make it equal, but I couldn't.
I am using phonegap 3.5
config.xml
<plugin name="StatusBarNotification" value="com.phonegap.plugins.statusBarNotification.StatusBarNotification"/>
index.html
<body>
<div class="app">
<h1>PhoneGap</h1>
<button onclick="sendNotification()"> Mensaje</button>
</div>
</div>
</div>
<script type="text/javascript" src="js/statusbarnotification.js"></script>
<script type="text/javascript" charset="utf-8">
function sendNotification() {
window.plugins.statusBarNotification.notify("Sample Notification", "mensajito");
}
</script>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
It looks like the plugin you are using is not for Cordova/PhoneGap >= version 3.0.
Since 3.0, everything should be done via the CLI, including installing plugins: https://cordova.apache.org/docs/en/3.0.0/guide_cli_index.md.html
You then don't include references to any plugin javascript, as Cordova takes care of this.
You can search for compatible plugins on either of these 2 sites:
http://plugreg.com
http://plugins.cordova.io
Hopefully this helps.
I'm have trouble using the widget dojox.mobile.TextBox in my Android app.
Here is the simple html file:
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" href="dojo/dojox/mobile/themes/custom/custom.css" type="text/css" media="screen" title="no title" charset="utf-8">
<script type="text/javascript" charset="utf-8" src="js/cordova-2.6.0.js"></script>
<script type="text/javascript" charset="utf-8">
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
// Cordova is loaded and it is now safe to make calls Cordova methods
//
function onDeviceReady() {
}
</script>
</head>
<body onload="onLoad();">
<div>
<input data-dojo-type="dojox.mobile.TextBox" placeHolder="Enter LAST name" />
</div>
<script type="text/javascript" charset="UTF-8" src="dojo/dojo/dojo.js" ></script>
<script type="text/javascript" charset="UTF-8">
// Load the widget parser and mobile base
require([
"dojox/mobile/parser",
"dojox/mobile/deviceTheme",
"dojox/mobile/compat",
"dojox/mobile",
"dojox/mobile/TextBox"
], function(parser, deviceTheme) {
// Parse the page for widgets!
parser.parse();
});
</script>
</body>
</html>
And Here is the error I get:
06-04 15:22:52.304: E/Web Console(28791): Uncaught Error: declare dojox.mobile.TextBox: mixin #1 is unknown. Did you use dojo.require to pull it in? at file:///android_asset/www/dojo/dojo/dojo.js:15
I also tried with dojox.mobile.app.TextBox but then I get:
06-04 15:46:16.192: E/Web Console(29566): Uncaught TypeError: Cannot read property 'dynamic' of undefined at file:///android_asset/www/dojo/dojo/dojo.js:15
I made sure I have the last version of dojo.
If anybody has an answer it would really help me.
Thanks.
I would start by moving:
<script type="text/javascript" charset="UTF-8" src="dojo/dojo/dojo.js" ></script>
<script type="text/javascript" charset="UTF-8">
// Load the widget parser and mobile base
require([
"dojox/mobile/parser",
"dojox/mobile/deviceTheme",
"dojox/mobile/compat",
"dojox/mobile",
"dojox/mobile/TextBox"
], function(parser, deviceTheme) {
// Parse the page for widgets!
parser.parse();
});
into the head tag area and add "dojo/domReady!" to you dojo require block. You should probably add another thing in the head to configure dojo properly:
<script>dojoConfig = {
async: true,
parseOnLoad: true
}
</script>
You should study all the examples located here:
http://download.dojotoolkit.org/release-1.9.0/dojo-release-1.9.0/dojox/mobile/tests/
I followed official Sencha learning tutorial to setup my first phonegap app with sencha touch give on this link.
And here's my index.html code -
<!DOCTYPE html>
<html>
<head>
<title>Contacts</title>
<script type="text/javascript" src="lib/touch/sencha-touch-debug.js"></script>
<link href="lib/touch/resources/css/sencha-touch.css" rel="stylesheet"
type="text/css" />
<script type="text/javascript" src="app/app.js"></script>
<script type="text/javascript" src="cordova-1.8.1.js"></script>
<script type="text/javascript">
/* Ext.application({
name : "DemoApp",
launch : function() {
console.log("App launch");
}
}); */
</script>
<script type="text/javascript">
document.addEventListener("deviceready", DemoApp.launch, false);
</script>
</head>
<body>
</body>
</html>
And my app/app.js contains -
Ext.application({
name: 'DemoApp',
launch: function() {
this.launched = true;
this.mainLaunch();
},
mainLaunch: function() {
if (!device || !this.launched) {return;}
console.log('mainLaunch');
}
});
All the paths to the script are absolutely correct but still I get following error.
Uncaught ReferenceError: DemoApp is not defined at file:///android_asset/www/index.html:19
I also tried putting app.js in index.html itself but above error still persists. Sencha js and css are included correctly as I'm not getting any error regarding Ext not defined etc etc.
What else could be the reason. Any help is highly appreciated.
<script type="text/javascript" src="app/app.js"></script>
<script type="text/javascript" src="cordova-1.8.1.js"></script>
should be
<script type="text/javascript" src="cordova-1.8.1.js"></script>
<script type="text/javascript" src="app/app.js"></script>
I'm trying to get jqtouch zepto to work with phonegap. I'm using android to test. I have the project set up and both js frameworks loading but I get this error when setting up jqtouch
TypeError: Result of expression 'a' [undefined] is not an object. at file:///android_asset/www/jqtouch.min.js:7
And this is the error for the non min js jqtouch.
TypeError: Result of expression 'hash' [undefined] is not an object. at file:///android_asset/www/jqtouch.js:420
Here is what my header and initialization of jqtouch looks like
<script src="zepto.min.js" type="text/javascript" charset="utf-8"></script>
<script src="jqtouch.js" type="text/javascript" charset="utf-8"></script>
<script src="phonegap.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">
$.jQTouch({
icon: 'jqtouch.png',
statusBar: 'black-translucent',
preloadImages: []
});
</script>
As I understand your question this is before you even have compiled your project. If you have just imported jqtouch.min.js and jqtouch.js and Eclipse is saying there is an error in them you can set Eclipse to ignore the file for errors.
Go to : Project->Properties->JavaScript->Include Path->Source-> Excluded Groups
ignore specific files by adding **/jqtouch*.js
This will make Eclipse ignore the supposed errors in jqtouch.js and jqtouch.min.js and make you able to compile your project.