1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    63
    Vote Rating
    1
    msweltzdk is on a distinguished road

      0  

    Default TypeError: 'undefined' is not an object (evaluating 'firingFn.apply')

    TypeError: 'undefined' is not an object (evaluating 'firingFn.apply')


    I am using Sencha Touch 2.0 PR4

    I am trying to add a listener to a button event.

    If I add the code like this, everything works fine:

    Code:
    control: {
         btnAddParticipant: {                
              tap: function () {
    var participantsStore = Ext.getStore('Participants'),
    params = iBygning.app.getController('MainNavigation').getPersist(); Ext.apply(params, participantsStore.getProxy().getParams()); participantsStore.load({ params: params });
    }
    }
    },

    But if I change the code to what looks and feels more right like the following, I get the error written in the subject:

    Code:
    control: {
    btnAddParticipant: {
    tap: 'loadParticipantsOverlay'
    }
    }, loadParticipantsOverlay: function () {
    var participantsStore = Ext.getStore('Participants'),
    params = iBygning.app.getController('MainNavigation').getPersist();
    Ext.apply(params, participantsStore.getProxy().getParams());
    participantsStore.load({
    params: params
    });
    }
    Can someone guide me to what the issue I am having could be?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,047
    Vote Rating
    850
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Saying the event string you pass isn't on the class. This works for me:

    Code:
    Ext.define('MyContainer', {
        extend : 'Ext.Container',
        xtype  : 'mycnt',
    
        config : {
            items : [
                {
                    xtype : 'button',
                    text  : 'Test'
                }
            ],
    
            control : {
                'button' : {
                    tap : 'loadParticipantsOverlay'
                }
            }
        },
    
        loadParticipantsOverlay : function(btn) {
            console.log(btn);
        }
    });
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Jan 2012
    Posts
    63
    Vote Rating
    1
    msweltzdk is on a distinguished road

      0  

    Default


    First of, thanks for the reply.

    The only problem I have with your solution is that I don't want any logic in my views. I forgot to mention that my previous example is in a controller.

    btnAddParticipant is being defined via a ref, and it picks the tap event up nicely, just doesn't fire the event properly. (If I change the selector for the ref, the tap doesn't do anything)

  4. #4
    Sencha User
    Join Date
    Nov 2011
    Posts
    53
    Vote Rating
    0
    paul_todd is on a distinguished road

      0  

    Default


    Did you make sure your loadParticipantsOverlay method is outside of the config block?

  5. #5
    Sencha User
    Join Date
    Jan 2012
    Posts
    63
    Vote Rating
    1
    msweltzdk is on a distinguished road

      0  

    Default


    Thank you, paul_todd. For some reaons I had been staring blindly at such a silly mistake. Fixed.

Thread Participants: 2