1. #1
    Sencha User
    Join Date
    Jun 2010
    Posts
    134
    Vote Rating
    3
    jeanluca is on a distinguished road

      0  

    Default PhoneGap: TypeError: 'undefined' is not a function

    PhoneGap: TypeError: 'undefined' is not a function


    Hi

    I'm trying to wrap my Sencha Touch 2 app into a phonegap application. I'm new to xcode/phonegap development, but the only think I found on the web to get a little bit of debug info is to add the following to your index.html file

    Code:
     <script>window.onerror = function(error) { console.error(error); alert(error); };</script>
    So, the error I got was

    Code:
    2012-03-07 11:38:06.373 barebones-phonegap[30838:13403] [INFO] Error: [ERROR][Ext.viewport.Ios#undefined] Timeout waiting for window.innerHeight to change
    I found that changing autoMaximize to false solved this error

    Code:
    viewport : {                
        autoMaximize : false
    },
    However now I get the following error

    Code:
    2012-03-07 11:45:38.425 barebones-phonegap[30917:13403] [INFO] TypeError: 'undefined' is not a function
    Not very helpful. So how to debug javascript in xcode, I couldn't find much helpful info on the web.
    Any suggestions ?
    Furthermore, I found this link in which a UIWebView is suggested. Will this work ? Sounds like a very simple solution!!

    Cheers
    Luca


    Update: I've managed to get the main view (which is initially shown) to work. It show a list (items are loaded using a store). Anyway, if I click on a item/button I get the 'undefined is not a function' error, always!!

    UPDATE 2: I got it working If I remove the cordova-1.5.0.js file it works. I do get erros now 'variable cordova does not exist but if I remove the window.onerror line it works like a charm. Here is the index.html

    Code:
    <!DOCTYPE html><html>
      <head>
      <title></title>
          <!--
      <script>window.onerror = function(error) { console.error(error); alert(error); };</script>
        -->
           <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
        <meta charset="utf-8">
    <!--
        <script type="text/javascript" charset="utf-8" src="cordova-1.5.0.js"></script>
    -->    
    <link rel="stylesheet" href="generated/css/myapp.css" type="text/css">
            <script type="text/javascript" src="generated/js/app-all.js"></script>
            <script type="text/javascript" src="app/MyApp.js"></script>
      </head>
      <body></body>
    </html>
    So this should be something in ST I guess!?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,599
    Vote Rating
    434
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    So it works just fine when you removed cordova?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Jun 2010
    Posts
    134
    Vote Rating
    3
    jeanluca is on a distinguished road

      0  

    Default


    yes. Without cordova I can use the app without problems. With cordova included the app starts normally, but when you try to interact with the app the 'undefined is not a function' error occurs with every mouse click (I'm testing in the xcode iphone simulator)

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,599
    Vote Rating
    434
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Ok, sounds like cordova is placing a listener that is conflicting.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.

  5. #5
    Sencha User
    Join Date
    Jun 2010
    Posts
    134
    Vote Rating
    3
    jeanluca is on a distinguished road

      0  

    Default


    ok, what does that mean for now ?

  6. #6
    Sencha User
    Join Date
    Jan 2012
    Posts
    16
    Vote Rating
    0
    crankin is on a distinguished road

      0  

    Default


    s

Tags for this Thread