1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    17
    Vote Rating
    0
    shanndee is on a distinguished road

      0  

    Default Unanswered: Created custom xtype resulted to Uncaught Error

    Unanswered: Created custom xtype resulted to Uncaught Error


    I created a tab panel and this is found in app.js. In one of the items I have this
    Code:
    {
              xtype: 'homepanel'
     },

    in my Home.js, i also have this for view
    Code:
    Ext.define('Sencha.view.Home', {
        extend: 'Ext.Panel',
        xtype: 'homepanel',
        
        config: {
            title: 'Home',
            iconCls: 'home',
            cls: 'home',
            html: 'Home',
            html: [
               '<h1>Title',
               '<p>Description</p>'
            ].join("")
        }
    and this for the controller
    Code:
    Ext.define('Sencha.controller.Main', {
        extend: 'Ext.app.Controller',
        
        views: ['Home'],
        
        init: function() {
            console.log('inited');
        }
    });
    The console is able to log the 'inited' so the connection to the controller is established. However, there is an error and is says:

    Uncaught Error: [Ext.createByAlias] Cannot create an instance of unrecognized alias: widget.homepanel

    What have I done wrong?
    Thanks for your help.

  2. #2
    Sencha Premium Member
    Join Date
    Oct 2011
    Location
    Huntsville
    Posts
    227
    Answers
    6
    Vote Rating
    -6
    mark0978 is infamous around these parts mark0978 is infamous around these parts

      0  

    Default


    Ext.define('Sencha.view.Home', {
    extend: 'Ext.Panel',
    //xtype: 'homepanel',
    alias: 'widget.homepanel', // its xtype when you use it, not when you define it.

  3. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    17
    Vote Rating
    0
    shanndee is on a distinguished road

      0  

    Default


    Quote Originally Posted by mark0978 View Post
    Ext.define('Sencha.view.Home', {
    extend: 'Ext.Panel',
    //xtype: 'homepanel',
    alias: 'widget.homepanel', // its xtype when you use it, not when you define it.
    I understand what you mean, unfortunately, this doesn't work for me and it gives the same error. do you have any other options?

  4. #4
    Sencha Premium Member
    Join Date
    Oct 2011
    Location
    Huntsville
    Posts
    227
    Answers
    6
    Vote Rating
    -6
    mark0978 is infamous around these parts mark0978 is infamous around these parts

      0  

    Default


    That's the way I do it and it works for me.

  5. #5
    Sencha User
    Join Date
    Mar 2012
    Posts
    17
    Vote Rating
    0
    shanndee is on a distinguished road

      0  

    Default


    I was actually following the video tutorials from here to the letter

    http://docs.sencha.com/touch/2-0/#!/video/mvc-part-1

    but i got stuck in this line. I am using the RC2 version. Any suggestions why mine does not work?

  6. #6
    Sencha User
    Join Date
    Mar 2008
    Posts
    47
    Answers
    2
    Vote Rating
    0
    mchambaud is on a distinguished road

      0  

    Default


    your app.js needs to have views: ['Home']

    something like this
    Code:
    Ext.Loader.setConfig({
        enabled: true
    });
    
    Ext.application({
        name: 'My App',
    
        models: [],
    
        stores: [],
            
        views: ['Home'],
    
        controllers: [],
    
        launch: function () {
            Ext.create('myApp.view.Viewport');
        }
    });
    everything else looks fine, xtype should work i dont think you need to switch to alias and I don't think you need views:['Home'] in the controller

  7. #7
    Sencha User
    Join Date
    Feb 2011
    Posts
    18
    Vote Rating
    0
    DavorZ is on a distinguished road

      0  

    Question


    I also have this problem, following all the steps with Ed Spencer presentation on SenchaCon 2011 and keep getting this error, I am using Sencha Touch 2.0 RC2, everything works fine so I know i am settin up project fine, only XTYPE: is throwing error? Can enybody look at this code, what are we doing wrong so we keep getting this error?

  8. #8
    Sencha User
    Join Date
    Mar 2008
    Posts
    47
    Answers
    2
    Vote Rating
    0
    mchambaud is on a distinguished road

      0  

    Default


    post your code

  9. #9
    Sencha User
    Join Date
    Mar 2012
    Posts
    17
    Vote Rating
    0
    shanndee is on a distinguished road

      0  

    Default


    A very simple mistake. I forgot to include the home.js in my index.html. Thank you all anyway.

  10. #10
    Sencha User
    Join Date
    Mar 2012
    Posts
    9
    Vote Rating
    0
    danrockstheplanet is on a distinguished road

      0  

    Default I'm getting the same problem

    I'm getting the same problem


    I'm trying to follow along with the video tutorial on http://docs.sencha.com/touch/2-0/#!/...etting_started, and the error happens (for me), when he gets to 5:15. I've rewatched the previous 1-2 minutes about 10 times, can't figure out what I'm doing wrong.On Win 7 64-bit.