1. #1
    Sencha User
    Join Date
    Mar 2008
    Posts
    20
    Vote Rating
    0
    bernex is on a distinguished road

      0  

    Default Unanswered: Controller events after destroy()

    Unanswered: Controller events after destroy()


    I cant understand, why come doesnt work.

    http://new.senchafiddle.com/#/cAcbe/

    Code:
    Ext.Loader.setConfig({
        enabled : true
    });
    
    Ext.define('Test.controller.Main', {
        extend : 'Ext.app.Controller',
    
        config : {
            refs : {
                mybtn : '#btn'
            },
    
            control : {
                mybtn : {
                    tap : 'onButtonTap'
                }
            }
        },
    
        onButtonTap : function(button) {
            var container = button.up('container');
    
            container.remove(button);
    
            container.add({
                id: "btn",
                xtype : 'button',
                text  : 'New Button ' + new Date().getTime()
            });
        }
    });
    
    Ext.application({
        name : 'Test',
    
        controllers : [
            'Main'
        ],
    
        launch : function () {
    
            new Ext.Container({
                fullscreen : true,
                items      : [
                    {
                        xtype : 'button',
                        id:"btn",
                        text  : 'Test'
                    }
                ]
            });
    
        }
    });
    If I change
    Code:
    mybtn : '#btn'
    to
    Code:
    mybtn : 'button'
    work!

    Thanks!

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,604
    Answers
    3449
    Vote Rating
    818
    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


    The listener gets applied to the single instance and doesn't free up. Instead of your control statement using the ref, try using '#btn' to see if that helps:

    Code:
    control : {
        '#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.

Thread Participants: 1