1. #1
    Sencha User
    Join Date
    Aug 2011
    Posts
    36
    Vote Rating
    2
    Answers
    4
    bjudson is on a distinguished road

      0  

    Default Answered: Sencha Cmd app build package & relayEvents()

    Answered: Sencha Cmd app build package & relayEvents()


    I have this on a component in a Sencha Touch 2.1 app:

    PHP Code:
    initialize: function() {
        
    this.callParent(arguments);
        
    this.relayEvents(this.element, ['tap''drag']);

    And then I catch that in a controller in the normal way:

    PHP Code:
    cmpRef: {
        
    tap'onCmpTap'
    }, 
    This works fine in Chrome and iPhone simulator when testing against the unprocessed JavaScript. But after I use app build package with Sencha Cmd 3, the event is no longer fired. I couldn't find anything about this in the forums, but I've tried it in a few different situations and it always seems to fail in the packaged build.

    Anyone encountered this problem before?

  2. Found the solution to this one: create a custom component. The initialize event you see above was defined on a component within an items list of another component:

    Code:
    {
        xtype: 'container',
        layout: {
            type: 'vbox',
            pack: 'center'
        },
        flex: 1,
        items: [
            {
                xtype: 'container',
                itemId: 'storyPlayer',
                cls: 'storyPlayer',
                tpl: ['...'],
                initialize: function() {
                    this.callParent(arguments);
                    this.relayEvents(this.element, ['tap']);
                }
            }
        
        ]
    }
    Like I said, this worked with the unoptimized JavaScript, but after packaging it with Sencha Cmd, the initialize event was simply ignored. Don't know why. So I pulled that out into a custom component, like so:

    Code:
    Ext.define('MyApp.view.cmp.StoryPlayer', {
        extend: 'Ext.Container',
        xtype: 'storyplayer',
    
    
        config: {
            tpl: ['...']
        },
    
    
        initialize: function() {
            this.callParent(arguments);
            this.relayEvents(this.element, ['tap']);
        }
    });
    and referenced this component within the other view, and it started working.

  3. #2
    Sencha User
    Join Date
    Aug 2011
    Posts
    36
    Vote Rating
    2
    Answers
    4
    bjudson is on a distinguished road

      0  

    Default


    I upgraded to the newest version of Sencha Cmd (3.1.1.274), but that didn't help.

  4. #3
    Sencha User
    Join Date
    Aug 2011
    Posts
    36
    Vote Rating
    2
    Answers
    4
    bjudson is on a distinguished road

      0  

    Default


    Found the solution to this one: create a custom component. The initialize event you see above was defined on a component within an items list of another component:

    Code:
    {
        xtype: 'container',
        layout: {
            type: 'vbox',
            pack: 'center'
        },
        flex: 1,
        items: [
            {
                xtype: 'container',
                itemId: 'storyPlayer',
                cls: 'storyPlayer',
                tpl: ['...'],
                initialize: function() {
                    this.callParent(arguments);
                    this.relayEvents(this.element, ['tap']);
                }
            }
        
        ]
    }
    Like I said, this worked with the unoptimized JavaScript, but after packaging it with Sencha Cmd, the initialize event was simply ignored. Don't know why. So I pulled that out into a custom component, like so:

    Code:
    Ext.define('MyApp.view.cmp.StoryPlayer', {
        extend: 'Ext.Container',
        xtype: 'storyplayer',
    
    
        config: {
            tpl: ['...']
        },
    
    
        initialize: function() {
            this.callParent(arguments);
            this.relayEvents(this.element, ['tap']);
        }
    });
    and referenced this component within the other view, and it started working.