1. #1
    Sencha User
    Join Date
    Sep 2011
    Posts
    36
    Vote Rating
    0
    user14 is on a distinguished road

      0  

    Default Unanswered: Define new class, create object of that type. Just to memorize syntax

    Unanswered: Define new class, create object of that type. Just to memorize syntax


    In Java we create class:
    PHP Code:
    class MyClass

        
    String name;   // <-- instance variable

        
    MyClass(String name) {      // <-- constructor
            
    this.name=name;
         }

        
    void DisplayName(){      //  <-- any class method
              
    System.out.println(name);
        }

    And now we can create object :
    PHP Code:
    MyClass   myClassVar =  new MyClass("John"); 
    After object created , we can invoke method on it:
    PHP Code:
    myClassVar.DisplayName(); 
    PLEASE: Show me the same in ExtJS !
    I mean define class and create var ( instance of that type)

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,927
    Answers
    656
    Vote Rating
    443
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

  3. #3
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    4,913
    Answers
    371
    Vote Rating
    179
    slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold

      0  

    Default


    Code:
    Ext.define('MyClass', {
        name: undefined
        , displayName: function () {
            alert(this.name)
        }
    });
    
    var self = Ext.create('MyClass', { name: 'John' });
    
    self.displayName();

Thread Participants: 2