1. #1
    Sencha User
    Join Date
    Apr 2012
    Location
    Fort Lauderdale
    Posts
    7
    Vote Rating
    0
    MedFrog is on a distinguished road

      0  

    Default Answered: Button Hander in MVC Architecture

    Answered: Button Hander in MVC Architecture


    Button Hander in MVC Architecture

    I am trying to set the handler for a button, but I am having no luck.

    I have the following excerpt from config section:
    {
    xtype: 'button',
    text: 'Stop',
    id: 'stopButton',
    handler: 'onButtonTap'
    }
    below after the config I have the following function:

    onButtonTap: function(e, eOpts) {
    console.log('hello');
    }

    But my function doesn't get called. What am I doing wrong? Also, does my function need to be in my controller? Or can I have it in the view?

  2. First of all, I would recommend you to read all the articles in Learn section and watch the videos to get the general idea and understanding of the Sencha concepts. I'm also relative new to Sencha Touch and this information was the good starting point for me.

    However,
    If you want to have the handler function in the view (that doesn't seem to be the best approach) then you have to change your code as the following:

    PHP Code:
    {
        
    xtype'button',
        
    text'Stop',
        
    id'stopButton',
        
    handlerthis.onButtonTap
    }

    onButtonTap: function() {
        
    console.log('hello');

    If you want to make this in MVC style, then you'd better write something like this:

    In your view:
    PHP Code:
    {
        
    xtype'button',
        
    text'Stop',
        
    action'stop'   

    Then in your controller:
    PHP Code:
    config: {  
          
    refs: {
                      
    stopButton'button[action=stop]'
         
    },
         
    control: {   
              
    stopButton : {   
                    
    tap 'onStopButtonTap'  
              

         }
    },

    onStopButtonTap : function() {
        
    console.info('Hello');


  3. #2
    Ext JS Premium Member
    Join Date
    Mar 2010
    Location
    Moldova, Republic of / Shelton, CT, US
    Posts
    154
    Answers
    3
    Vote Rating
    5
    amsoft is on a distinguished road

      0  

    Default


    First of all, I would recommend you to read all the articles in Learn section and watch the videos to get the general idea and understanding of the Sencha concepts. I'm also relative new to Sencha Touch and this information was the good starting point for me.

    However,
    If you want to have the handler function in the view (that doesn't seem to be the best approach) then you have to change your code as the following:

    PHP Code:
    {
        
    xtype'button',
        
    text'Stop',
        
    id'stopButton',
        
    handlerthis.onButtonTap
    }

    onButtonTap: function() {
        
    console.log('hello');

    If you want to make this in MVC style, then you'd better write something like this:

    In your view:
    PHP Code:
    {
        
    xtype'button',
        
    text'Stop',
        
    action'stop'   

    Then in your controller:
    PHP Code:
    config: {  
          
    refs: {
                      
    stopButton'button[action=stop]'
         
    },
         
    control: {   
              
    stopButton : {   
                    
    tap 'onStopButtonTap'  
              

         }
    },

    onStopButtonTap : function() {
        
    console.info('Hello');


Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi