How can I integrate Sencha Touch 2 into Cordova (Phonegap) project

时光总嘲笑我的痴心妄想 提交于 2019-12-06 06:54:31

问题


I'm trying to integrate a ST2 app into PhoneGap; but I'm having problems.

I've added cordova.js into app.json:

{   
    "path": "resources/js/cordova-1.6.1.js",
    "update": "delta"
},
{   
    "path": "resources/js/test.js",
    "update": "delta"
}

Test.js :

function alertDismissed() {}

function showAlert() {
    navigator.notification.alert(
        'You are the winner!',  // message
        alertDismissed,         // callback
        'Game Over',            // title
        'Done'                  // buttonName
    );
}

Inside a view, i've created a dummy button:

items: [{
    text: 'test',
    action: showAlert(),
}],

When i tap the button; the function 'showAlert()' is fired up correctly; but not being executed correctly i have an error :

Uncaught TypeError: Cannot call method 'alert' of undefined

Obviously because the object 'navigator' is not being instenciated.

Question: is it possible to have both cordova/senchatouch2 run ? If so, what is the proper way to do it ?

SOLVED:

Add cordova.js prior to app.js

    {   
        "path": "resources/js/cordova-1.6.1.js",
        "update": "delta"
    },
    {
        "path": "sdk/sencha-touch.js"
    },
    {
        "path": "app.js",
        "update": "delta"
    },

回答1:


Just include the cordova.js file from the index.html file.




回答2:


Here is a good article about "A Sencha Touch MVC application with PhoneGap" http://www.sencha.com/learn/a-sencha-touch-mvc-application-with-phonegap/




回答3:


you can refer following blog to integrate senchatouch and phonegap with custom plugin:

http://hynridmobileapps.blogspot.in/



来源:https://stackoverflow.com/questions/10384596/how-can-i-integrate-sencha-touch-2-into-cordova-phonegap-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!