Wait! Looks like we don't have enough information to add this to bug database. Please follow this template bug format.
  1. #1
    Sencha User
    Join Date
    Feb 2013
    Posts
    28
    Vote Rating
    0
    hectorgomis is on a distinguished road

      0  

    Default Events not working after dinamic Delete View and Create New View

    Events not working after dinamic Delete View and Create New View


    I'm developing a simple ST2 App. I have a modal view showed "onbuttontap", but after user taps "Accept", I delete this modal view. When user wants to open the modal view again, I create this view (no problem), but after it is showed to the user, the events of the buttons are not working. I'm using ST2.2.0 and ST2.1.0, and are not working in both. I think there is a bug with events, because are not firing again.

    Main view
    Code:
    Ext.define('App.view.Main', {
        extend: 'Ext.Panel',
    
        config: {
            height: '100%',
            width: '100%',
            items: [
                           {
                            xtype: 'button',
                            id: 'btnShowModal',
                            text: 'Show Modal'
                            }
                    ]
                }
    });
    Modal view
    Code:
    Ext.define('App.view.Popup', {
        extend: 'Ext.Panel',
    
        config: {
            centered: true,
            height: '80%',
            id: 'popup',
            width: '80%',
            modal: true,
            hideOnMaskTap: true,
            scrollable: true,
            items: [
                           {
                            xtype: 'button',
                            id: 'btnAccept',
                            ui: 'confirm',
                            text: 'Accept'
                            }
                    ]
                }
    });
    Main Controller
    Code:
    Ext.define('App.controller.Main', {
        extend: 'Ext.app.Controller',
    
        config: {
            control: {
                "#btnAccept" : {
                    tap: 'onBtnAcceptTap'
                },
                "#btnShowModalTap": {
                    tap: 'onBtnShowModalTap'
                }
            }
        },
       
        onBtnAcceptTap: function(button, e, eOpts) {
            Ext.Viewport.remove(Ext.getCmp('popup'), true);
        },
    
        onBtnShowModalTap: function(button, e, eOpts) {
            if(Ext.getCmp('popup'))
            {
                Ext.Viewport.remove(Ext.getCmp('popup'), true);
            }
            var view = Ext.create('ClaveiSAT.view.Popup');
            Ext.Viewport.add(view);
        }
    });

    I've found a way to solve it, but I don't really like. This way consist to move the controller logic to the view side. In this case, the event are working everytime like that:


    Code:
    // at the end of the view 
    
    
            listeners: [
                {
                    fn: 'onBtnAcceptTap',
                    event: 'tap',
                    delegate: '#btnAccept'
                }
            ]
        },
        onBtnAcceptTap: function(button, e, eOpts) {
                 Ext.Viewport.remove(Ext.getCmp('popup'), true);
        }

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,656
    Vote Rating
    435
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Does it help if you stop using the id config and use a selector with xtypes and properties?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    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 almost in print!

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

  3. #3
    Sencha User
    Join Date
    Feb 2013
    Posts
    28
    Vote Rating
    0
    hectorgomis is on a distinguished road

      0  

    Default


    Can you give an example, please?