1. #1
    Sencha User
    Join Date
    Aug 2012
    Posts
    6
    Vote Rating
    0
    caleem@gmail.com is on a distinguished road

      0  

    Default Unanswered: new to Sencha, need a kick to start started - Problem with class creation

    Unanswered: new to Sencha, need a kick to start started - Problem with class creation


    hi,
    I have created following class for Sencha, but it doesn't show the alert message.
    Can someone tell me whats wrong with the code?

    Also 1. do i need tp copy Person class under a separate file under folder structure My\sample ??
    2. if there is any error how can I check that, I am using trial version and google chrome.

    comments and suggestion are appropriated, thank you...
    here is the code below.

    Ext.application({


    name: 'HelloExt',
    launch: function(){

    Ext.define('My.sample.Person',{
    name: 'John';
    constructor: function (name){
    if (name){
    this.name = name;
    }
    }

    eat: function(foodtype){
    alert(this.name + ' is eating ' + foodtype );
    }
    });


    var k = Ext.create('My.sample.Person', 'JJ');
    k.eat('fishhh');

    }


    });

  2. #2
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    1. do i need tp copy Person class under a separate file under folder structure My\sample ??
    If you just need to check a class, you can put it directly in your code as you did with your example. However, it is often a class is used for more than one place in your code, so you should put it in a separate file. You should look at this manual to see more information about naming classes, where to store them, etc : http://docs.sencha.com/ext-js/4-1/#!/guide/class_system

    2. if there is any error how can I check that, I am using trial version and google chrome.
    You should use Tools\Developer tools which is included in Chrome.

    Below are some errors in your code:
    Code:
    Ext.application({
        name: 'HelloExt',
        launch: function(){
            Ext.define('My.sample.Person',{
                name: 'John', // ; <- comma instead of semicolon
                constructor: function (name){
                    if (name){
                        this.name = name;
                    }
                }, // missing comma
                eat: function(foodtype){
                    alert(this.name + ' is eating ' + foodtype );
                }
            });
    
    
            var k = Ext.create('My.sample.Person', 'JJ');
            k.eat('fishhh');
        }
    });
    P/S: You should put your code by using CODE tag, then you will have more opportunity of getting support from community.

  3. #3
    Sencha User
    Join Date
    Aug 2012
    Posts
    6
    Vote Rating
    0
    caleem@gmail.com is on a distinguished road

      0  

    Default thanks....

    thanks....


    its working fine now,

    is there any way where I can check the error log ??

    there should be some place where I can check the log and come to know that i have added semi colon inplace of comma.

    <code>
    Ext.application();
    </code>

  4. #4
    Sencha User
    Join Date
    Aug 2012
    Posts
    6
    Vote Rating
    0
    caleem@gmail.com is on a distinguished road

      0  

    Default


    <CODE>
    Ext.Application();
    </CODE>

  5. #5
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    Just use Tools\Deverloper tools that comes with Chrome browser.