Reputation: 6210
I wrote simple phonegap application for testing deviceready
:
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/>
</head>
<body>
<script src="js/main.js"></script>
</body>
<html>
main.js
window.addEventListener("deviceready", function() {
alert("Device is ready");
});
But the alert is never firing. I have added the android platform by running
$ phonegap platform add android
in the app's root directory (the one containing the www folder), but it still didn't solve the problem. I've also read many answers (here, here and here) to this problem, but none worked for me. What could the issue be?
Edit: Thanks for pointing out the mistake. Changed deviceReady
to deviceready
.
Upvotes: 1
Views: 201
Reputation: 4466
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/>
//**Note:** src is path for cordova.js
<script type="text/javascript" src="js/cordova.js"></script>
</head>
<body>
<script src="js/main.js"></script>
</body>
<html>
main.js
$(document).ready(function () {
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
// Alert
}
});
Upvotes: 1