Events on the phone do not work on iphone

I have real problems with PhoneGap on the iPhone with events. The app runs pretty smoothly on my Android device, but it does nothing on my iPhone. For example, a simple code:

<!DOCTYPE HTML>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0;" />
    <meta charset="utf-8">
    <title>WayAcross Mobile Application</title>
    <link rel="stylesheet" href="css/jquery.css" />
    <link rel="stylesheet" href="css/screen.css" />
    <link rel="stylesheet" href="css/login.css" />      
    <script type="text/javascript" charset="utf-8" src="jquery/jquery.js"></script>
    <script type="text/javascript" charset="utf-8" src="jquery/jquery.mobile.js"></script>
    <script type="text/javascript" charset="UTF-8" src="javascript/mainJavascript.js"></script>
        <script type="text/javascript" charset="utf-8">

            // Call onDeviceReady when PhoneGap is loaded.
            //
            // At this point, the document has loaded but phonegap.js has not.
            // When PhoneGap is loaded and talking with the native device,
            // it will call the event `deviceready`.
            //
            function onLoad(){
                document.addEventListener("deviceready", onDeviceReady, false);
            }

            // PhoneGap is loaded and it is now safe to make calls PhoneGap methods
            //
            function onDeviceReady() {
                // Now safe to use the PhoneGap API
                alert('ready');
            }

            </script>
        <script type="text/javascript" charset="utf-8" src="javascript/phonegap.js"></script>
</head>
<body onload="onLoad()">

(This is an example of code that does not work with iPhone and works with Android).

I think this is a problem with events, but I'm not sure. Even the code examples in PhoneGap docs do not work. My environment:

Thanks Advance.
Regards,
Elkas


By the way, I installed OSX Lion 10.7.2 and Xcode 4.2 now. Even in iOS5 it does not work. It drives me crazy!!! Even with this simple code does not work.

<!DOCTYPE html>
<html>
<head>
    <title>PhoneGap Device Ready Example</title>

    <script type="text/javascript" charset="utf-8">

        // Call onDeviceReady when PhoneGap is loaded.
        //
        // At this point, the document has loaded but phonegap.js has not.
        // When PhoneGap is loaded and talking with the native device,
        // it will call the event `deviceready`.
        // 
        document.addEventListener("deviceready", onDeviceReady, false);

        // PhoneGap is loaded and it is now safe to make calls PhoneGap methods
        //
        function onDeviceReady() {
            alert('Hello World');
        }

        </script>
    <script type="text/javascript" charset="utf-8" src="javascript/phonegap.js"</script>
</head>
    <body>
    </body>
</html>
+5
5

!

phonegap.js, . , , .

+1

addevent document.ready .. .

$(document).ready(function(){
document.addEventListener("deviceready",function(){

},false);
});
+1

Phonegap iOS (..) phonegap.1.4.1.js.

(, cordova.1.8.0.js) , .

Phonegap, "" .

phonegap.1.4.1.js, .

+1

, , , XCode .... script jquery/ javascript/. XCode , , . , ( , ).

, , - script, .

0
function testDialog() {
    document.addEventListener("deviceready", onDeviceReady, false);
    function onDeviceReady() {
        navigator.notification.alert("This is message", function(){}, "HaHa", "Done");
    }
}
0

All Articles