Uncaught-TypeError-Cannot-call-method-substring-of-undefined-sencha-touch-all.js

微笑、不失礼 提交于 2019-12-14 03:18:42

问题


I am a new to Sencha Touch, though I have little knowledge about MVC, I am getting an error while I try to build an application following the video tutorial of Sencha Touch 2 as:

Uncaught TypeError: Cannot call method 'substring' of undefined sencha-touch-all.js:35

The code is as follows:

app.js:

Ext.Loader.setConfig({
    enabled: true


});
Ext.application({
    name: 'SBR',
    controllers: [
        'Main'
    ],
    launch: function(){
        Ext.create('Ext.TabPanel',{
            fullscreen: true,
            tabBarPosition: 'bottom',
            items: [
            {
                xtype: 'homepanel'
            },
            {
                xtype: 'carousel',
                title: 'Blog',
                iconCls: 'star',
                html: 'Student Blog',
                items: [
                {
                    xtype: 'image',
                    src: 'resources/images/icon1.png'
                },
                {
                    xtype: 'image',
                    src: 'resources/images/icon2.png'
                }]

            },
            {

                title: 'Enter your Comments',
                iconCls: 'star',
                html: 'Enter your Comments'
            }

            ]

        });
    }
});

Home.js - the View

Ext.define('SBR.view.Home', {
    extend: 'Ext.Panel',
    xtype: 'homepanel',
    config:{
        title: 'Home',
        iconCls: 'home',
        html: 'Html through View'
    }
});

Main.js - The Controller

Ext.define('SBR.controller.Main',{
    extend: 'Ext.app.Controller',
    views: ['Home'],
    init: function(){
        console.log('It is tested - Ok');
    }
});

If the code of the view (Home.js) is set in the app.js without using a xtype, it works fine, but when I define a view and try to access the view by xtype from app.js it does not work and throws the above exception, although it logs the message passed in the controller successfully in the console.

Browser Used : Chrome

IDE : Aptana

Sencha Touch Version: 2.0


回答1:


You need to add all the View, Store and Model classes in app.js just the same way you added the controller:

controllers: [
        'Main'
],
views : [
    'Home'
]

This should make it work.



来源:https://stackoverflow.com/questions/16439771/uncaught-typeerror-cannot-call-method-substring-of-undefined-sencha-touch-all-js

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