简体   繁体   中英

Sencha Touch Making a simple button work

I have a hard time debugging and understanding why the most basic stuff is going wrong in my sencha project. I use webstorm, but it can't seem to help me much with missspelling code. Most errors i get are unclear like undefined is not a function. Can anyone help me by showing me what I do wrong in the following code. I just want a button that does a console log.

View:

    Ext.define('imp.view.Test', {
        extend: 'Ext.form.Panel',
        alias: "widget.test",
        xtype: 'test',
        controllers: 'imp.controller.Test',
        requires: [ 'imp.controller.Test'],

        config: {
            title:'Test',
            scrollable: null,
            items: [

                {
                    xtype: 'button',
                    itemId: 'postButton',
                    ui: 'action',
                    padding: '10px',
                    text: 'Post'
                }]


        }

});

Controller:

Ext.define('imp.controller.Test', {
    extend: 'Ext.app.Controller',
    config: {
        refs: {
            testView: 'test'
        },
        control: {
            'test #postButton': {
                tap: 'onPostCommand'
            }
        }
    },

        onPostCommand: function (){
            console.log('klik');


        }

    }
);

What is a good way to debug and to learn Sencha Touch better, could anyone give me some advice? What books,sites etc. are good?

Update: This is the console log output and when i press the butotn just nothing happens.....

development.js:21 Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.
development.js:22 XHR finished loading: GET "http://imp.localhost/imp/bootstrap.json".
development.js:9 GET http://imp.localhost/imp/cordova.js 
sencha-touch.js:13036 The key "minimum-ui" is not recognized and ignored.
Abstract.js?_dc=1427878432368:27 The 'overflowchanged' event is deprecated and may be removed. Please do not use it.
Console.js?_dc=1427878432463:35 [WARN][Anonymous] [Ext.Loader] Synchronously loading 'imp.store.Offline.Opdrachten'; consider adding 'imp.store.Offline.Opdrachten' explicitly as a require of the corresponding class
sencha-touch.js:8381 XHR finished loading: GET "http://imp.localhost/imp/app/store/Offline/Opdrachten.js?_dc=1427878433743".
sencha-touch.js:8381 XHR finished loading: GET "http://imp.localhost/touch/src/data/ArrayStore.js?_dc=1427878433755".
sencha-touch.js:8381 XHR finished loading: GET "http://imp.localhost/touch/src/data/reader/Array.js?_dc=1427878433767".
Console.js?_dc=1427878432463:35 [WARN][Anonymous] [Ext.Loader] Synchronously loading 'imp.store.Offline.Antwoorden'; consider adding 'imp.store.Offline.Antwoorden' explicitly as a require of the corresponding class
sencha-touch.js:8381 XHR finished loading: GET "http://imp.localhost/imp/app/store/Offline/Antwoorden.js?_dc=1427878433786".
Connection.js?_dc=1427878433330:375 GET https://simplemanager.transfer-solutions.com/ords/simplemanager/test1/planningen 401 (Unauthorized)
Connection.js?_dc=1427878433330:375 XHR finished loading: GET "https://simplemanager.transfer-solutions.com/ords/simplemanager/test1/planningen".

The best way to find out if there is something wrong with your code is using Firebug in Firefox or Developer Tools in Chrome.

Referring to your problem, I just removed the util.Utility from the code and it works fine. So you want to make sure if there is any Utility.js in the app/util folder. Also, Utility.js should follow Sencha class structure:

Ext.define('.util.Utility', { /*upper case "U" in important*/
      config : {
      }
});

At the end, you should see either the klik or an error in the console output.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM