Disco
Disco

Reputation: 4396

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

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"
    },

Upvotes: 3

Views: 7889

Answers (3)

user447390
user447390

Reputation: 69

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

http://hynridmobileapps.blogspot.in/

Upvotes: 0

Ouadie
Ouadie

Reputation: 13175

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/

Upvotes: 1

Oras
Oras

Reputation: 1096

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

Upvotes: 3

Related Questions