javascriptioscordovainclude

Calls to phonegap.js


When my button is clicked, nothing happens.

<button onclick="captureVideo();">Capture Video</button>

I've put phonegap-1.4.1.js in the WWW folder.

I've included <script src="javascript/phonegap-1.4.1.js" type="text/javascript"></script> in my head section.

I did all the supporting functions, as per PhoneGap API Docs' example.

<script>
        // Called when capture operation is finished
        //
        function captureSuccess(mediaFiles) {
            var i, len;
            for (i = 0, len = mediaFiles.length; i < len; i += 1) {
                uploadFile(mediaFiles[i]);
            }       
        }
        
        // Called if something bad happens.
        // 
        function captureError(error) {
            var msg = 'An error occurred during capture: ' + error.code;
            navigator.notification.alert(msg, null, 'Uh oh!');
        }
        
        // A button will call this function
        //
        function captureVideo() {
            // Launch device video recording application, 
            // allowing user to capture up to 2 video clips
            navigator.device.capture.captureVideo();
        }
        </script>

My other calls to other external js all work fine. Just phonegap-1.4.1.js isn't working. What am I missing here?

EDIT

When I pasted the PhoneGap js inline, then all my calls to those functions worked fine. So, I've established that the problem was it never loaded from externally. Deviceready alerts will tell me the same thing, but it doesn't MAKE it load. So, the question remains, how can I get the external js to load?


Solution

  • The file is here:

    I've put phonegap-1.4.1.js in the WWW folder.

    But you're including it in a different location:

    I've included <script src="javascript/phonegap-1.4.1.js" type="text/javascript"></script> in my head section.

    It's not loading because it expects to find the file inside a javascript directory, while you've put it in the www folder. Make a dir "javascript" inside the www folder, or remove "javascript" from the src in your script tag.