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
    Posts
    104
    Answers
    1
    Vote Rating
    0
    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

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar